X Tutup
Skip to content

Fix LookAtModifier3D / AimModifier3D forward vector#115689

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
TokageItLab:fix-look-at-mod
Feb 5, 2026
Merged

Fix LookAtModifier3D / AimModifier3D forward vector#115689
Repiteo merged 1 commit intogodotengine:masterfrom
TokageItLab:fix-look-at-mod

Conversation

@TokageItLab
Copy link
Member

@TokageItLab TokageItLab commented Jan 31, 2026

LookAtModifier

  • It was not correctly considering its own bone_rest (or bone_pose when relative=true), this bug is exist from 4.4.
    • In other words, while this issue can be reproduced in 4.4 when the neck and head rests differ (even if relative option is disabled), since the neck and head rests are usually the same in most cases, the bug likely remained largely unnoticed and unreported.
  • However, when relative is enabled, it seems difficult to apply restrictions only to the rest (so it cannot work similar to JointLimitation in IK). I added a note to the documentation, but considering this, the relative setting for the LookAtModifier should probably be false. I assume the relative setting for the AimModifier should remain true (it was changed in Add relative option to LookAt/AimModifier3D #111367 (review)). cc @lyuma
    • When applying limitations to Euler rotations, it can be defined their range as a rectangle such as PhysBones - Polar. However, the problem is that flip detection and other functions such as dumping are based on the Euler rotation axes, making immediate fixes here difficult. Although, it might be possible to send a follow-up PR later as an additional relative option like “keep limitation rest”.

Before (left: relative = false/ right: relative = true):

look_at_before.mp4

After fix (left: relative = false/ right: relative = true):

look_at_fixed.mp4

AimModifier

  • If target is node (added in 4.6), it was not accounting for the skeleton's own rotation, causing the vector pointing toward the target to break when the skeleton moved.

Before (left: AimModifier / right: LookAtModifier):

aim_before.mp4

After fix (left: AimModifier / right: LookAtModifier):

aim_fixed.mp4

aim_lookat_demo.zip

@TokageItLab TokageItLab added this to the 4.7 milestone Jan 31, 2026
@TokageItLab TokageItLab requested a review from a team January 31, 2026 20:42
@TokageItLab TokageItLab requested review from a team as code owners January 31, 2026 20:42
@TokageItLab TokageItLab added topic:animation topic:3d cherrypick:4.6 Considered for cherry-picking into a future 4.6.x release labels Jan 31, 2026
@TokageItLab TokageItLab force-pushed the fix-look-at-mod branch 2 times, most recently from e127947 to cfe020e Compare January 31, 2026 21:21
@fire
Copy link
Member

fire commented Feb 3, 2026

I am not able to review this in depth, but I agree that it fixes an important issue and it should be merged for the new point release of 4.6

Copy link
Contributor

@lyuma lyuma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lyuma: Why are the rotation limits affected by relative? Are the limits relative to the target in one case?

Tokage: If only the limitation is unaffected by relative as you said, we can consider such a state. While not entirely intuitive at this point, the issue is that we must also consider whether damping and flip detection are individually affected by relative. The only immediately applicable fix is to ensure everything is affected by relative

Lyuma: Okay, so to clarify, the difference is between aim and lookat has to do with use of euler. I think rest is the only thing that makes sense for defining the limit but that can produce odd behaviors if the current pose is outside the range

I now understand why Aim constrain will continue to have relative default to true, while for lookat this default is not feasible. It might be good to document this subtle difference of default relative in the docs of AimConstraint.

Given this explanation, I agree with the proposed change. We need this to be included in 4.6.1

@fire
Copy link
Member

fire commented Feb 5, 2026

I moved this to ready to merge for 4.6 too. Let me know if there's a problem with that.

@Repiteo Repiteo merged commit 21932ac into godotengine:master Feb 5, 2026
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Feb 5, 2026

Thanks!

@Repiteo
Copy link
Contributor

Repiteo commented Feb 5, 2026

Cherry-picked for 4.6.1.

@Repiteo Repiteo removed the cherrypick:4.6 Considered for cherry-picking into a future 4.6.x release label Feb 5, 2026
rivie13 pushed a commit to rivie13/Phoenix-Agentic-Engine that referenced this pull request Feb 16, 2026
Fix LookAtModifier3D / AimModifier3D forward vector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LookAtModifier3D ignores Time Based Interpolation when Relative Option is True

5 participants

X Tutup