making the char. stop on certain angled slopes

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

Hello
I’m moving my KB2D with move_and_slide_with_snap
I was wandering if someone can help me to completely stop my KB2D if encountering slopes from a certain angle(over 45 degrees to be exact

note: my slopes are staticbody2D

var snap_dir = Vector2.DOWN
var snap_length = 32
var snap_threshold = deg2rad(45)
var snap_vector = snap_dir*snap_length

var up = Vector2.UP
var motion = Vector2.ZERO

func _physics_process(delta):
motion.y=move_and_slide_with_snap(motion,snap_vector , up , true ,4 ,snap_threshold).y
motion.y += gravity
y_movement()

func y_movement(delta):
if is_on_floor():

motion.y = 0
if Input.is_action_pressed(“ui_up”):
motion.y = max_jump_height
motion =move_and_slide(motion,up) # that’s how I disable snap
else:
motion.x = lerp(motion.x , 0 , 0.28)