system
June 29, 2019, 10:45am
1
Attention
Topic was automatically imported from the old Question2Answer platform.
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
system
June 29, 2019, 6:03pm
2
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.