How to walk up on slopes(Kinemtic)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Serenade
:warning: Old Version Published before Godot 3 was released.

Hey!
I made Kinematic2D player, but it cant walk on stairs which have like 45~ degree collision shape (square split in diognal)… How can i change the friction or smt to enable player to walk on that angle?

:bust_in_silhouette: Reply From: avencherus

One solution is to put a small raycast near the ankles of the player, making sure to switch its direction when the player turns. (And adjust it’s length and position as needed.)

Then when a collision is detected, check if it is a slope, then use the vector slide() function.

Using the collision normal obtained by the raycast and slope collision, and with the player’s velocity, a new movement vector will be created. It will point the player along the edge of the slope.