Skip to content
Tutorials Center
My learning

Topics

Lesson 29 of 38 ยท Animation and AI

Animation Blueprints and State Machines

Drive character animation in Unreal Engine. Skeletal meshes, the Anim Graph and Event Graph, locomotion state machines, transition rules and how to feed them speed and falling state.

A character mesh in a T-pose is not much use. Unreal Engine animates characters with skeletal meshes (a mesh bound to a hierarchy of bones), animation sequences (recorded motion for that skeleton) and an Animation Blueprint that decides, every frame, which animation to show and how to blend between them.

The Unreal Editor is not available on this site, so this lesson describes the editor workflow in words. The Python stand-ins implement a small state machine so you can see the logic.

Assets you need

  • Skeleton: the bone hierarchy. Animations are tied to a skeleton asset (and compatible skeletons can share them through retargeting).
  • Skeletal Mesh: the visible mesh with skin weights.
  • Animation Sequence: keyframed motion, such as Idle, Walk, Run, Jump Start, Jump Loop, Land.
  • Physics Asset: collision capsules for ragdoll and hit detection.
  • Animation Blueprint (ABP): the logic asset, created with right-click > Animation > Animation Blueprint and choosing the skeleton.

A character Blueprint (a Character subclass) has a Mesh component. In its Details, under Animation, set Animation Mode to Use Animation Blueprint and pick your ABP in Anim Class. The third-person template does this for you with the Mannequin.

Two graphs, two jobs

An Animation Blueprint has two main graphs:

Event Graph runs on the game thread each frame. Its usual job is to read data from the owner and store it in variables:

Text
Event Blueprint Update Animation (DeltaTimeX)
    Try Get Pawn Owner -> Cast to Character
    Speed      = Vector Length (Get Velocity) 
    IsFalling  = Movement Component > Is Falling

In C++ the equivalent is a class derived from UAnimInstance that overrides NativeUpdateAnimation(float DeltaSeconds). Newer projects prefer thread-safe updates (BlueprintThreadSafeUpdateAnimation) so this work can run on worker threads, but the idea is the same.

Anim Graph is the pose pipeline. It ends in an Output Pose node and may contain state machines, blend nodes, layered blends, IK nodes and slots for montages. It does not run game logic; it turns variables into a final pose.

State machines

Inside the Anim Graph you add a State Machine (right-click > State Machines > Add New State Machine) and name it Locomotion. Double-click to open it: you will see an Entry node. Drag from Entry to make a state, for example Idle. A typical locomotion machine has:

  • Idle (plays the idle animation or a blend space)
  • Move (a blend space driven by Speed, see Blend spaces and montages)
  • JumpStart, InAir, Land

Between states you draw transitions. Click a transition's circle to open its rule, a boolean graph:

  • Idle to Move: Speed > 3
  • Move to Idle: Speed < 3
  • Any ground state to JumpStart: IsFalling
  • InAir to Land: NOT IsFalling

Each transition also has a Blend Duration (how long to crossfade, for example 0.15 to 0.25 seconds), a Blend Logic (Standard Blend or Inertialization) and an optional Priority Order when several transitions leave the same state.

Add a small hysteresis gap (3 up, 2 down in the example) so the machine does not flicker between two states at the threshold.

Locomotion states

Idle Speed near zero
Move Speed above threshold
In air Is falling
Land Touches ground

Transitions are boolean rules

1 / 2

A state machine in Python

The stand-in models states, transition rules and a frame loop, using a character that accelerates, jumps and lands. It is a teaching model, not Unreal code.

Python Stand-in: locomotion state machine

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Note that on the first frame the machine takes only one transition per update. Unreal evaluates transitions the same way: the first rule that passes (in priority order) wins.

Blending between states

When a transition fires, the machine crossfades from the old pose to the new pose over the blend duration. The stand-in below computes a linear crossfade of one bone angle.

Python Stand-in: crossfade blend

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Other Anim Graph nodes worth knowing

  • Blend Poses by Bool / Enum: switch between poses (for example armed vs unarmed).
  • Layered Blend per Bone: play an upper-body animation (shooting) over lower-body locomotion, blending from the spine_01 bone up.
  • Slot nodes: the entry point for Montages, one-off animations such as attacks or reloads.
  • Two Bone IK / Control Rig / Foot IK: pin feet to uneven ground or aim a hand at a target.
  • Linked Anim Graphs and Anim Layers: split a big graph into reusable pieces.
  • Cached Poses: reuse a pose in several places.

Debugging

While playing in the editor (PIE), select the character and choose its Anim Blueprint in the Debug Object dropdown; the graph then shows live data and highlights the active state and transitions. Use ShowDebug Animation in the console to see an on-screen view.

Common mistakes

  • Doing game logic in the Anim Graph. Keep it a pure function of variables; compute the variables in the update function.
  • Flickering transitions. Add a gap between enter and leave thresholds.
  • Mismatched skeleton. An animation made for a different skeleton asset will not appear in the asset picker. Retarget it instead.
  • Long blend times on short actions. A 0.5 s blend on a 0.4 s attack makes it feel mushy.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Where do you usually copy gameplay data such as Speed into variables for an Animation Blueprint?

    The update function reads owner data once per frame and stores it; the Anim Graph then uses those variables.
  2. 2. What defines when a state machine moves from Idle to Move?

    Each transition has a rule that returns true when the machine should switch.
  3. 3. Why use different thresholds for entering and leaving Move?

    A small gap (hysteresis) stops the machine from toggling every frame around a single threshold value.
  4. 4. Which node plays an upper-body attack over lower-body locomotion?

    Layered Blend per Bone blends a second pose from a chosen bone, such as the spine, upward.

Summary

  • Skeletal meshes, skeletons and animation sequences are driven by an Animation Blueprint.
  • The Event/update function gathers variables; the Anim Graph turns them into a pose.
  • State machines use transition rules and blend durations; add hysteresis to avoid flicker.
  • Layered blends, slots and IK extend the basic setup.

Next: Blend Spaces and Montages