SebLague/2DPlatformer-Tutorial

Velocity.x never hits 0 unless you jump

Closed this issue · 1 comments

Hi Sebastian,

Thank you so much for the tutorials, I have found an issue in my code which I believe is an issue in the base code but has no direct impact on the platformer functionality.

Using Mathf.SmoothDamp for velocity x with a fixed float as you do in the code seems to keep it looping between -10 and 10, it never resets to 0 unless you jump and land. I discovered this as I had implemented some code to not start climbing a wall unless a player pressed against that wall.

I have worked around the issue by using inputs for my wall climb detection, however I can't seem to figure out how to fix the smoothdamp. Setting Time.deltatime instead of the accelerationTime just results in immediate stopping. I'll submit a pull request if I ever figure it out

It looks like this is just the behaviour for smoothdamp, it takes 6-8 seconds for the velocity.x to actually hit 0, I missed the E signifying how small the numbers were