How do I prevent the player from sliding down a slope?

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

My player character keeps sliding down slopes in my game. I’ve tried following tutorials on how to fix this issue, but none of them have worked.
If you need to know exactly how I’ve programmed the player character’s movement, the code can be found here: my player code -

What version of Godot are you using and what have you tried?

TRAILtheGREAT | 2023-04-27 23:44

# warning-ignore:return_value_discarded
move_and_slide_with_snap(Velocity, Vector3.UP)

You shouldn’t ignore this value, which may modify the velocity. But also, a snap vector should be supplied which is the direction of the slope, e.g. likely Vector2.DOWN (unless the object is not on the floor, e.g. jumping). There’s also an additional parameter stop_on_slope that defaults to false; change to fit your game.

KinematicBody2D — Godot Engine (3.5) documentation in English

I assume this is 3.x as move_and_slide_with_snap differs in 4.0.

spaceyjase | 2023-04-28 08:27