0 votes

I have a kinematic body that the player controls but I can't figure out how to slow the speed of it over time. I have tried putting a static body underneath it in order to have a friction value but it doesn't seem to affect the kinematicbody. any tips?

asked Oct 12 in Engine by xofox (90 points)

1 Answer

0 votes
Best answer

The easiest way to do this is with lerp(). For example:

velocity.x = lerp(velocity.x, 0, friction)

Where friction is some value between 0 and 1. This will cause the player's horizontal speed to gradually ramp down to 0 from its current value.

You can see this in practice with a full explanation here:
http://kidscancode.org/godot_recipes/physics/kinematic_friction/

answered Oct 12 by kidscancode (11,768 points)
selected Oct 12 by xofox
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.