PixPoly
All videos

Directional starts in Unreal Engine 5: the right animation from the first step

6:36

A single start animation, whatever the direction, shows immediately. With an Enum, a Select and a Sequence Player in Dynamic Value, the character starts correctly forward, left, right or in a turn.

Chapters

  1. 00:00Introduction
  2. 00:28Project overview
  3. 01:04Start state — setting up the Sequence Player
  4. 01:40On Become Relevant
  5. 02:12Creating the E_StartAnim Enum
  6. 03:30Start Direction Movement
  7. 06:20Result

In a classic locomotion system, the Start state always plays the same clip: the character sets off forward even when the player pushes the stick backward. The body then reorients itself, more or less. You can do far better, and without duplicating the state.

The idea: a single Start state, but a Sequence Player whose animation is chosen on entering the state, according to the real direction of the start.

A Sequence Player in Dynamic Value

In the Start state, replace the fixed animation with a Sequence Player — reusing the sync settings the rest of the locomotion relies on.

  1. 1Select the Sequence Player, Sequence line, click Bind and enable Dynamic Value.
  2. 2Still in the bindings, create the On Become Relevant function.
  3. 3Name it something like Update Anim Start.

On Become Relevant runs once, each time you enter the state. That is exactly what we want: the animation is chosen at the moment of the start, not every frame.

Inside the function, from the node output: Convert to Sequence Player — the pure version, the one with the green F — then Set Sequence. A Select node wired into its input will let you pick among several animations.

The direction Enum

The Select needs an index. An Enum makes it readable: right-click in the Content Drawer ▸ Blueprints ▸ Enumeration, named E_StartAnim, with five entries.

  • Forward — starting forward.
  • Left — starting to the left.
  • Right — starting to the right.
  • Backward Left — turning around to the left.
  • Backward Right — turning around to the right.

Then create a Movement Start Anim variable of that type in the Animation Blueprint, and drop it into the Select index. Each entry gets its animation.

No dedicated left and right animations? The quick-turn clips often do the job, as long as they are generic enough. A Start ▸ Cycle transition raised to 0.3 helps hide the approximation.

Working out the start direction

What is left is feeding the Enum. The code goes into the Blueprint Thread Safe Update Animation function — or into the Event Graph if you have not gone Thread Safe.

The principle fits in one sentence: you remember the character’s orientation while he is standing still, and compare the direction of his movement to that orientation the moment he sets off.

  1. 1Take the Is Acceleration variable and convert it into a Branch.
  2. 2On False — the character is idle — a Property Access on Get Actor Rotation of the character, promoted to an Actor Rotation Idle variable.
  3. 3On True, a Calculate Direction node: Base Rotation gets Actor Rotation Idle, Velocity a Property Access on the Character Movement velocity.

Calculate Direction returns an angle between -180 and 180: the gap between the direction of movement and where he was looking while stopped. All that is left is to cut it into ranges with In Range Float nodes.

RangeDirectionValue
-45 to 45Straight aheadForward
45 to 135To the rightRight
-135 to -45To the leftLeft
-180 to -90Turning around to the leftBackward Left
Everything elseTurning around to the rightBackward Right

Group the calculation into a function — Get Movement Start Direction — with the Enum as return value, and tick Thread Safe if you are working inside the function of the same name. The variable is set on the way out, not inside: the main graph then tells the whole story in three nodes.

The result

The character sets off in the right direction from the first frame, turns included, and without an extra state in the State Machine. Adding a direction later means adding an Enum entry and an angle range.