Course contentsShow
← Unreal Engine Game Development
Lesson 311 of 8805. Animation and Character RiggingFree lesson

Implementing Blend Spaces for Fluid Locomotion

Learners will create 2D blend spaces to interpolate between walk, run, and idle animations based on velocity.

In this lesson, you will learn how to use a 2D Blend Space to create smooth, natural transitions between idle, walking, and running animations based on your character’s movement speed.

Understanding the 2D Blend Space

A Blend Space is an animation asset that allows you to blend multiple animations together based on input values (parameters). While a 1D Blend Space uses a single axis (like speed), a 2D Blend Space uses two axes, allowing for more complex movement, such as blending between idle, walk, and run while simultaneously accounting for directional movement (like strafing).

To set this up:

  1. Right-click in your Content Browser, navigate to Animation, and select Blend Space 2D. Choose your character's skeleton.
  2. Inside the editor, look at the Axis Settings in the Asset Details panel. Set the Horizontal Axis to Speed (0 to 600) and the Vertical Axis to Direction (-180 to 180).
  3. Drag your idle, walk, and run animations from the Asset Browser onto the grid. Place "Idle" at Speed 0, "Walk" at Speed 200, and "Run" at Speed 600.

Blending by Velocity

Unreal Engine handles the "fluid" part of locomotion by calculating the weight of each animation based on where the character's current velocity sits on that grid. If your velocity is 300, the engine performs a weighted blend between your Walk and Run animations.

To apply this in your AnimGraph, you don’t just plug in an animation; you create a "Blend Space Player." You must then promote the Axis inputs to variables:

// Logic often found in the Event Graph of your Animation Blueprint
// Get the character's velocity from the Pawn Owner
FVector Velocity = TryGetPawnOwner()->GetVelocity();
// Calculate speed and direction to feed the Blend Space
Speed = Velocity.Size();
Direction = CalculateDirection(Velocity, TryGetPawnOwner()->GetActorRotation());

By connecting these Speed and Direction variables to your Blend Space node, your character will transition seamlessly between animations, preventing the "snapping" or stuttering look that happens when switching between discrete animation clips.

Key Takeaway: 2D Blend Spaces allow you to map animation states to a coordinate system, enabling the engine to mathematically interpolate between poses for fluid, realistic movement.