bevyengine / bevyengine/bevy

Vector subtraction in `look_at` inverts the forward vector

Open
#1,153 9 comments 0 reactions 0 assignees View on GitHub
A-Transform C-Bug C-Docs S-Needs-Design
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

**Bevy version**

0.4.0

**Operating system & version**

Linux

**What you did**

Calling `forward` on a `Transform` created by `look_at` gives the result in what appears to be the wrong direction.

**What you expected to happen**

I was expecting `forward` called on a `Transform` (for a `Camera`) created by `look_at` to be pointing towards the target.

**What actually happened**

It was pointing backwards.

**Additional information**

The code of `look_at` looks like:
`let forward = Vec3::normalize(self.translation - target);`

This means the vector `forward` will go from `target` to `self.translation`, so in reality it will be pointing backward from the `target`, instead of forward...

Are we in some Camera-local coordinate system here, with the directions inverted? Maybe I'm just confused...

Contributor guide

Open the contributing guide

Research direction

Start by inspecting the Transform::look_at implementation and the forward call described in the report. Verify the engine's camera-local direction convention and whether the subtraction matches the documented target-facing behavior; done means the reported direction is consistent and the behavior is covered by an appropriate regression check.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.