PixPoly
All videos

Animation Blueprint: going Thread Safe to carry the load on Unreal Engine 5

6:09

Almost every tutorial updates animation variables in the Event Graph. The result: everything runs on a single core. Here is how to move that code into a Thread Safe function, and what has to change for it to compile.

Chapters

  1. 00:00Introduction
  2. 00:46Blueprint Thread Safe Update Animation
  3. 01:25Property Access
  4. 03:02Update Ground Friction
  5. 04:05Velocity Z
  6. 04:24Slope
  7. 05:51Result

If you update your animation variables in the Event Graph — the way nearly every tutorial shows — all of those calculations run on a single thread, therefore on a single CPU core. With one character, nobody notices. With fifty NPCs on screen, it is a bottleneck.

Unreal has offered the fix for a long time, but it sees little use because it refuses to compile until you have understood its rules. Here they are.

Moving the code into the right function

Cut everything downstream of Event Blueprint Update Animation — the sequence and the variable updates. In Functions ▸ Override, pick Blueprint Thread Safe Update Animation, and paste it in there.

This function does the same thing as the event, with one difference: its contents can run in parallel across several cores. Compile — and you get a pile of errors. That is normal, and that is where the real work starts.

The rule is simple: inside a Thread Safe function you can **read** data, never **write** it. Anything that changes a state has to leave the Animation Blueprint.

Property Access: reading without breaking anything

The usual calls — Get Velocity, Get Last Movement Input, Get Current Acceleration — are not multithread-safe. The Property Access node replaces them: Unreal prepares a copy of the data, safe to read.

  1. 1Add a Property Access node in place of the existing call.
  2. 2Inside it, look for your character reference — the one created by the cast, at Animation Blueprint initialisation.
  3. 3Drill down to the property you want: Velocity, Last Movement Input, or a whole component such as Character Movement.
  4. 4Wire it up, delete the old node, compile.

Property Access drills into components: from the character reference you reach Character Movement ▸ Current Acceleration directly. And it can pull a single axis — Velocity ▸ Z — without a Break Vector.

What has to move into the character

Two things will never go Thread Safe, and they have to move into the character Blueprint.

The first is any variable write. If you were changing Ground Friction from the Animation Blueprint — to make the character slide through a quick turn, say — that code has to move into the character, after the movement action. Group it into a function (right-click, Collapse to Function) named something like Update Ground Friction: the graph stays readable.

The second is the line trace. The function that reads the ground normal, to lean the character on slopes, uses one — and a line trace is not thread safe. Move that logic into the character, and create the Slope variable there as a float.

Once Slope lives on the character, delete the one in the Animation Blueprint. Everywhere the AnimGraph used it — in the start, in the cycle — a Property Access will read it straight off the character.

The result

No errors left, and identical behaviour: the character runs, jumps, falls and turns around exactly as before. The difference is invisible on screen — it shows up in the profiler, and above all the day you put fifty characters in the same level.