Just in case somebody else runs into this problem. The issue is that while you can set move_and_slide
to not slide down slopes, the gravity is still used to calculate the movement against the slope's normal.
A simple fix for me was to cancel out the sideways movement caused by the gravity pushing the character against the slope. This can be calculated with the floor normal.
A simple example:
velocity = ....
velocity = player.move_and_slide(velocity, Vector3.UP, true)
The previous snippet would result in downwards movement when moving sideways and different speeds for going up and down the slope, like this weird movement
However, if we take the floor normal and multiply it by the affecting gravity, we can cancel out the effect
var correction = Vector3(0,0,0)
if player.is_on_floor():
correction = Vector3(0,1,0) - player.get_floor_normal()
correction *= GRAVITY
correction *= -1
velocity = ....
velocity = player.move_and_slide(velocity + correction, Vector3.UP, true)
Our player will now behave as if it was walking on a flat surface.