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.
- 1Select the Sequence Player, Sequence line, click Bind and enable Dynamic Value.
- 2Still in the bindings, create the On Become Relevant function.
- 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.
- 1Take the Is Acceleration variable and convert it into a Branch.
- 2On False — the character is idle — a Property Access on Get Actor Rotation of the character, promoted to an Actor Rotation Idle variable.
- 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.
| Range | Direction | Value |
|---|---|---|
| -45 to 45 | Straight ahead | Forward |
| 45 to 135 | To the right | Right |
| -135 to -45 | To the left | Left |
| -180 to -90 | Turning around to the left | Backward Left |
| Everything else | Turning around to the right | Backward 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.