-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tilt correction wrong if up != Vec3::Y
#40
Comments
Originally When I did the big refactor of version 0.10, I did many changes - two of them I think are relevant to the confusion:
So if previously it was clearer that The current Maybe I really should replace |
Now that I think about it - maybe the As for the |
I think I'm encountering a similar issue. I've been adjusting gravity in my world to be a line from my character to the center of the globe (origin), but my character wants to stand upright to Is there a way I can change the |
Awesome, thanks for this fix! Note that I'm close on having an update to the demo that allows you to switch between the flat world and a spherical world. |
@rltvty When you change the gravity to fit the player's position, what happens to the other rigid bodies? I assume your spherical world is small enough to have a noticeable curve. but AFAIK both Rapier and Avian only support a uniform gravity... |
I think there's an error here: the
tilted_up
vector should be calculated as the tracked rotation applied to the y-axis rather than toself.up
:bevy-tnua/src/builtins/walk.rs
Lines 282 to 284 in 5fdc7c2
The
rotation_required_to_fix_tilt
line makes sense - the desired "equilibrium" position is that wheretilted_up == self.up
. However, computingtilted_up
astracker.rotation * self.up
means this condition becomesself.up = tracker_rotation * self.up
, so the resulting equilibrium character transform is a rotation aroundself.up
(in world-space) rather than a rotation of the "character-space" up vector (the y-axis) onto the desired world-space up vectorself.up
.This leads to some odd-looking effects in-game when rotating the
desired_forward
direction of a character withself.up
set to the normal of an angled floor.Changing line 282 to
solved these issues for me in local testing.
Hopefully this makes sense and I'm not just misinterpreting the intended usage of the
up
vector or something. Happy to open a PR if you'd prefer but that felt a bit overkill for a +/- 7-character proposed changeThe text was updated successfully, but these errors were encountered: