Slopes and step offset
Walk up ramps and small steps without bouncing or sticking.
Box-shaped characters treat a ramp like a wall or launch off the top of it, and a 2 px ledge stops them dead. Good movement moves along the slope surface, sticks to the ground going downhill, refuses slopes that are too steep, and steps up small ledges automatically.
Try this: Walk right over the ramp and the small step with handling off: you bounce down the slope and stop at the step. Turn it on with G.
Walk over the ramp and the step.
Prompt bit
Works for 2D or 3D in any engine (Unity, Unreal, Godot, web). Paste the short one for a quick fix, or the detailed one when you want it done properly.
Handle slopes and steps: move along the ground surface instead of straight sideways, snap down within 0.2 units while walking downhill, treat slopes over 45 degrees as walls, step up ledges under 0.3 units, and skip snapping for 0.1 s after a jump.
Make the character controller handle slopes and steps (2D platformers and 3D, any engine; Unity CharacterController has slopeLimit and stepOffset, Godot CharacterBody has floor_max_angle and floor_snap_length, so configure those first). Each physics step, get the ground normal under the feet. Project the horizontal input velocity onto the ground plane so walking uphill and downhill keeps the same speed along the surface. When grounded and not jumping, snap down: cast down up to a snap distance (default 0.2 units or 4 px) and move the character onto the hit so it does not launch off crests or bounce down ramps. Treat surfaces steeper than the max slope angle (default 45 degrees) as walls and slide off them. For steps, if a short forward cast at foot height hits but a cast at step height (default 0.3 units) does not, lift the character onto the step. Turn off snapping for 0.1 s after a jump starts. Show a debug line for the ground normal while tuning.
Where it's used
- 2D platformers: hills and ramps without bouncing
- 3D action and adventure: stairs and uneven terrain
- First-person games: step offset for stairs
- Racing and kart games: sticking to banked tracks
- Isometric games: walking over raised tiles
Common mistakes
Moving horizontally into slopes so speed changes uphill and downhill, no ground snap so characters bounce down ramps and launch off crests, snapping during jumps so jumps get cancelled, and step offsets so big that characters climb walls.
Writing this with an AI assistant? See our best AI coding assistants for game developers.
Missing a concept? Request one.



