Help me go down stairs without “flying”

Godot Version

4.5.1

Question

How do I implement a system for going down stairs? I am a beginner in Godot and programming in general. I managed to write an extremely simple code for going up stairs, but when going down, the character flies instead of being stuck to the floor of the stairs or ramp. I tried a few methods, but they are all very complicated, and I would like to do something that I can understand. I use a raycast to detect if there is ground in front or if it is a free fall, but all the codes I used interfered with walking normally or caused some other problem.

Maybe do a check, that if the player is not on the ground (I.e started falling) check if there is ground beneath them up to a maximum “step distance” and if there is, then push the player down until they are grounded again.

Make sure do to this the first frame after they stop being grounded, otherwise regular falling will cause the last little distance above the ground to snap down

Try modifying the CharacterBody3D.floor_snap_length property

I imagine you collision looks like this

The simplest way to bypass a problem like this is to have the collision like this instead

Also when your player is moving downwards have a check to see if the raycast hits stairs (having it on a specific collision layer is easiest) and adjust either to snap the player to the ground or change the gravity of the player to have it stick to the ground more than fly forward.

1 Like

You can do that in many ways,here is a cool video that explains it :

and as @mrcook mentioned ,you can just use a plane collision