Course contentsShow
← Unreal Engine Game Development
Lesson 102 of 8802. The Gameplay FrameworkFree lesson

Handling Slopes and Ledges

You will configure movement constraints to ensure your character correctly navigates complex geometry like steep slopes and uneven terrain.

In this lesson, you will learn how to fine-tune your CharacterMovementComponent to ensure your character navigates steep inclines and uneven terrain without getting stuck or sliding uncontrollably.

Controlling Slope Navigation

When building levels, you will inevitably encounter hills and staircases. If a slope is too steep, you don’t want your player to walk up it like it’s flat ground. Unreal Engine handles this through the CharacterMovementComponent. Specifically, it uses two main properties to define the threshold for what your character considers "walkable."

  • Walkable Floor Angle: This defines the maximum steepness (in degrees) that your character can climb. If a surface exceeds this angle, the character will be treated as if they are standing on an "unwalkable" surface, causing them to slide down.
  • Walkable Floor Z: This is the cosine of the floor angle. Many developers prefer this because it represents the "flatness" of the ground. A value of 1.0 means perfectly flat, while 0.0 is a vertical wall.

You can adjust these settings in your Character Blueprint by selecting the CharacterMovement component and looking at the Movement Capabilities section in the Details panel.

Addressing Ledges and Edges

Handling ledges is about deciding how your character behaves when there is no floor beneath them. By default, the CharacterMovementComponent has a feature called "Walkable Slope Behavior."

If you set this to Walkable Slope Behavior: Increase Character Velocity, you can allow the character to "jump" slightly when hitting a sharp edge rather than catching on the geometry. This helps avoid the "jittery" feeling often found in early-stage platforming.

Here is how you might tweak these settings via code in your character’s constructor:

// Within your Character constructor
GetCharacterMovement()->SetWalkableFloorAngle(45.0f); // Limit climbing to 45 degrees
GetCharacterMovement()->bConstrainToPlane = false;   // Ensure we handle slopes naturally

By tweaking these values, you stop your character from "snapping" to surfaces they shouldn't be on, ensuring a smooth transition between flat plains and challenging mountains.

Key Takeaway: Use the Walkable Floor Angle property to define your movement limits, ensuring your character intelligently identifies which surfaces are climbable and which are too steep to traverse.