Is it bad to have multiple move_and_slide () in physics_process (delta) :?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bgegg

It seems that it does not work well if it separates for movement and gravity.
Should it be one?

That it does not work sounds bad to me. Why not add movement and gravity together?

Dlean Jeans | 2019-06-29 17:10

:bust_in_silhouette: Reply From: kidscancode

This is the whole point of move_and_slide(). Use it once with your total movement vector. Make sure you capture the returned value, this is your resulting motion after slide.

# apply gravity
# apply inputs
velocity = move_and_slide(velocity, Vector2.UP)

See Using KinematicBody2D for details (same applies in 3D).

Thank you very much.
I use it only once.

bgegg | 2019-06-29 20:32