November 6, 2014

Animation Blueprints

By Lina Halper

Why Animation Blueprint?

"Animation Blueprint” sounds more intimidating than “Blueprint”. Blueprints were fun, but now Animation Blueprints seem to work different than Blueprints, so I wanted to talk about it here.

First, Let’s talk about how to play animation in Unreal Engine.

We have 2 ways to play animations on SkeletalMeshComponent. As you might know already, SkeletalMeshComponent contains a bone hierarchy with skinned mesh that you can play animations on. If you drag animations into the level, it creates a SkeletalMeshActor that contains a SkeletalMeshComponent and sets up some basic information for you.

Skeletal Mesh Actor

Note in particular this section of the data when you select the actor in detail panel.


Every SkeletalMeshComponent has an Animation Mode setting, in which we set one of the 2 ways of playing animation that I mentioned earlier.

  1. Use Animation Asset: This only applies to AnimSequence or AnimComposite. One asset that can produce a valid pose along the given timeline.
  2. Use Animation Blueprint: This mode allows you to play Animation Blueprint

The first option sounds simple, but the second needs more explanation.

The second option is to Use Animation Blueprint.

If you drag AnimBlueprint from the content browser to level viewport, it will create SkeletalMeshActor with the AnimBlueprint set up as shown in below. (Similar as the above action where you drag AnimSequence to the level viewport)

Animation Viewport

Playing one animation is simple, but playing multiple animations and blending each other based on different condition – i.e. playing different blended animation – is a bit more complicated, and that’s what Animation Blueprint is for. It works based on current state, such as parameters and current time.

If you create any Animation Blueprint, you’ll see 2 graphs, explained very well in this link.

It has two graphs - EventGraph and AnimGraph.

EventGraph is same as Blueprint for the AnimInstance. You can set variables or call functions and it has events that triggers. You have sequence of actions you execute by calling each node.

AnimGraph is a bit different. It is where animation is blended. You can think more as tree structure than sequence of actions. Each node has its own process step and as a result, it produces pose.

Let’s look at the example of Event Graph first.

Blueprint Diagram

Once you know Blueprint, this is very clear to understand. It triggers this event, Update Animation, and when that happens, it sets Speed, and sets Direction after Calculating direction.

Then how does AnimGraph work? AnimGraph works differently.

AnimGraph At Work

The above will play walk animation which goes to Final Animation Pose. The order of evaluation is still left to right, but the way you should think about each node is more of state than one off action. Currently it only has one animation that loops. In order for it to advance, each node has to save transient data. Thus, state.

What about when you’d like to blend two animation based on float value ranged from [0, 1]?

Animation Range

When we update the animation system, it will do following order of operations,

  1. Update EventGraph
  2. Update AnimGraph
  3. Trigger event

The reason we update EventGraph first is so that we can get all up-to-date variables, so that AnimGraph can use those values to blend accordingly.

This does not change anything on bone transform. All this does is to update the “state” of things based on time change. Then, when do we change bone transform and produce a valid pose for the frame? That happens in Evaluate.

We have 3 events happening in AnimGraph.

  1. Initialize
  2. Update
  3. Evaluate

EventGraph has only 2 events since EventGraph doesn’t need evaluate.

  1. Initialize
  2. Update

Usually, Initialize happens once, but if you change a mesh that “needs reinitialization”, it can happen again.

Update and Evaluate happens in every Tick. Evaluate is the one that produces the result of a valid pose. Why do we separate them? It’s mostly for optimization. Evaluation is the most expensive part of the animation process, where it does tons of math operations on transform, and we can parallelize easily since it doesn’t need any interaction with game. On the other hand, Update has “Trigger Event” – such as AnimNotifies - , which often means calling Blueprint functions. This needs interaction with other parts of the game, which makes it very difficult to parallelize.

Now what about changing bone transform? Where should that happen?

Most people seem to want to do this in their Blueprint. I think it’s more comforting to do that in Blueprint, but the proper place is to do this in Animation Blueprint.

Because Animation Blueprint is where it calculates all bone transforms and produces the final result. It would be better if we can do this in one place. If you do this in Blueprint, depending on order of Ticks, you might not get the latest bone transform. Let’s think about this scenario:

  1. Frame starts
  2. ….
  3. Your Blueprint updates bone transform
  4. Animation Blueprint gets called – update all bone transform
  5. ….
  6. Frame ends

This will void your changes since Animation Blueprint doesn’t care if you modified it or not. It will run the graph, and update transform accordingly. If we reverse the order, that would work.

  1. Frame starts
  2. ….
  3. Animation Blueprint gets called – update all bone transform
  4. Your Blueprint updates bone transform
  5. ….
  6. Frame ends

But now say there is other Blueprint that would like to change as well. This can get very complicated.

The best way is to centralize bone transform operations to happen in Animation Blueprint since one instance contains one animation blueprint. Use Transform Node to modify bone transform.

Transform Modify Bone Window

You can set which component of the transform you’d like to modify, as well as in what space.

Skeletal Control Window

Animation Blueprint is very powerful tool. It provides lots of nodes – i.e. layered blending, additive animation blending, blend by variables, state, transition, and so on. We have Animation.umap in the ContentExample project that you should check out.

Content Example

To learn more about them, go here and leave us any feedback.