How to make KinematicBody2D stop on slopes

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

Hello. So, as of now (Godot v3.2.3), the stop_on_slope parameter currently does nothing except break moving platforms. I have tried move_and_slide_with_snap() as well and it doesn’t fix it. Everything else I have tried (set velocity.y to 0, use RayShape2D, etc) either doesn’t work or messes everything up (specifically RayShape2D). I am aware that there is a workaround for this problem in 3D stop_on_slope doesn't seem to work in version 3.2 beta 3 · Issue #34117 · godotengine/godot · GitHub but it doesn’t work in 2D. Thank you for taking the time to read this.

hmm… hack it through by getting the angle of the slope?

bloodsign | 2021-03-30 18:10

Ok maybe getting the slope angle and then doing some math to set the gravity to go into the slope so it doesn’t slide(but only when on ground) may work. Also I may just do a feature proposal on github if it doesn’t work after that.

3ngin33r8086 | 2021-03-30 18:30

nvm I’ll bet the gravity thing won’t work. opening a feature request now.

3ngin33r8086 | 2021-03-30 19:52

You could use a RayCast2D pointing down to detect the ground and check for angle.

bloodsign | 2021-04-01 03:59

The most easiest is the answer above. I use raycast to program my AI to not fall unto ledges and slops

Mrpaolosarino | 2021-04-01 13:11

ok thank you; I’ve finally found a solution to get slope_stop to work here: move_and_slide_with_snap() gliding down slopes and workarounds dont work since RC3-5 etc · Issue #47042 · godotengine/godot · GitHub

3ngin33r8086 | 2021-04-01 21:40