+2 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?

in Engine by (92 points)

1 Answer

+3 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:

by (20,677 points)
selected by
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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.