idanarye / bevy-tnua

A floating character controller for Bevy

Home Page:https://crates.io/crates/bevy-tnua

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Character is pushed when moving platform changes direction

rparrett opened this issue · comments

To reproduce, run the platformer_3d example and hop onto the moving platform and then stay still.

When the platform changes directions, the character will be pushed slightly in the direction the platform was previously moving in.

moving_platform.mov

I notice that this is an acceleration issue. When I "disable" acceleration - that is, set it to infinity, which makes the character immediately move to its new velocity - the problem goes away. When I decrease the acceleration it becomes worse.

Peek.2023-04-06.00-07.mp4

What happens is that the platform changes velocity immediately. Say it is stationary, and then starts moving west at a speed of 4.0. This change of velocity happens immediately. From the character's point of view, though, he suddenly moves east at a speed of 4.0, while his target speed is 0.0. So he needs to decelerate. But unlike the platform, the character has a limit to his declaration - so it takes him some time, during which he moves a bit relative to the platform and plays his movement animation.

I should track the changes in the platform's velocity and add this acceleration to the character separate from the regular acceleration, so that the limits won't count. Though maybe if I do #10 I'll have to put a separate limit on that acceleration...