All Questions

Community

D
Seim2k

characters velocity does not decrease

when pressing left/right the character accelerate and moves, but the velocity does not decrease when releasing the direction button. i do not use the 2D game template. are there special peferences needed for the tielmap or st else that "move_and_slide()" function as intended (use friction to decrease speed...) ?

  • Nathan Lovato replied

    There's no friction when using the KinematicBody2D. You need to manually decrease the character's speed in your code.

    Here, we don't make the character decelerate when releasing an input key: instead, we stop it instantly.

    To make a character that decelerates smoothly, I recommend using steering behaviors. See this chapter to learn the basics: https://gdquest.mavenseed.com/lessons/introduction

  • D
    Seim2k replied

    Thanks for the answer,  i only wondered why the character didn't stop , now i set the velocity explicitly to 0 when releasing the move button.