bevyengine / bevyengine/bevy

Helper methods on `Transform`

Open
#14,426 4 comments 1 reaction 0 assignees View on GitHub
A-Transform C-Usability D-Straightforward S-Needs-Design
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?

Currently, working with a transform is cumbersome, requiring many lines to perform simple tasks. This can be seen easily in the [translation example](https://github.com/bevyengine/bevy/blob/main/examples/transforms/translation.rs):
```rust
let direction = transform.local_x();
transform.translation += direction * cube.speed * timer.delta_seconds();
```
Note that this has to be two lines instead of one, because of borrow checker issues.

## What solution would you like?

Simple methods like `translate`, `local_translate` would make such operations much simpler. The above could become
```rust
transform.local_translate(Vec3::X * cube.speed * timer.delta_seconds());
```
which is much simpler and easier to understand.

## What alternative(s) have you considered?

The original example does *work*, but as I said, it's quite cumbersome.

## Additional context

I know Unity has functions like these, although I don't know how many other engines do. Notably, Godot does not.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.