move_and_slide just for an axis

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

And how you can do the function move_and_slide() to affect only onw axis? I’ve seen this sentence in a 3.x tutorial, but I don’t know how to do the same in 4.x:

velocity.y = move_and_slide(velocity, Vector2.UP).y

Thanks in advanced.

:bust_in_silhouette: Reply From: spaceyjase
velocity += Vector2.Up * delta
move_and_slide()

There’s an example here, albeit it with Input. If the input is ignored in the example then there’s only one direction of movement.

Thanks for your help!

albertosanchezm | 2023-03-15 08:22