10 - AnimGraph

 


The AnimGraph is used to evaluate a final pose for the Skeletal Mesh for the current frame. By default, each Animation Blueprint has an AnimGraph which can have Animation Nodes placed within it to sample Animation Sequences, perform animation blends or control bone transforms using Skeletal Controls. The resulting pose is then applied to the Skeletal Mesh each frame.



Inside the AnimGraph, you can use values calculated in the EventGraph or elsewhere, likely in code, and use those as inputs for Blend Spaces or other blend nodes. Of course, you can also just sample Animation Sequences directly without any special blending. The AnimGraph also allows for the use of Skeletal Controls to modify bone positions, rotations, and scales directly.

Execution Flow

All graphs have a flow of execution shown as pulsing links between exec pins on the graph's nodes. For regular graphs, such as the EventGraph of a Blueprint, this flow is visualized during play as it is dependent on the firing of events. The AnimGraph is different in that it displays the flow of execution at all times since it is not event-based and is being evaluated each frame.



In the AnimGraph, the flow of execution represents poses being passed from one node to another. Some nodes, such as Blends, have multiple inputs and make a decision internally on which input is currently part of the flow of execution. This determination is usually dependent on some external input, like the value passed to a data pin.

In the example below, the same blend node from above switched the execution flow between its inputs based on the value of its Alpha pin (which is being manually set):



Blend with Alpha of 1.0 - Input B is used

Working with the AnimGraph

The AnimGraph works by evaluating a graph of nodes. Some of these nodes perform some specific operation on one or more input poses, while others are used to access or sample other types of assets, such as Animation Sequences, Blend Spaces or Anim Montages. State Machines, which contain their own graph networks can exist within the AnimGraph, and multiple State Machines can be blended together to produce a final output pose. Please refer to each link below for information on how each works within the context of the AnimGraph.

  • Animation Blending - can be accomplished through the use of various Blend Nodes.

  • Animation Nodes - are used to perform operations on input poses, such as blending, direct bone manipulation and more.

  • Animation Sequences - can be placed directly within the AnimGraph to drive a Final Animation Pose.

  • Blend Spaces - can be used within the AnimGraph to blend poses based on variables.

  • Skeletal Controls - are nodes which can be used to directly drive the bones within a Skeleton.

  • Space Conversion - are nodes that can change whether a pose is in local-space or component-space.

  • State Machines - are a series of graphs, rules and variables that determine an animation state for a character to enter.

  • Sync Groups - can be used to keep related animation that may have different lengths synchronized.

Thread Safety

AnimGraph logic can be run on worker threads using the "Use Multi-Threaded Animation Update" setting found in "Class Defaults". This can significantly improve the performance of games on multi-core machines by allowing animation work to complete in parallel with other updates.

If this setting is enabled (it is by default) then the compiler will warn if 'unsafe' operations are performed in the AnimGraph. Generally, safe operations are:

  • Using most AnimGraph nodes.

  • Directly accessing member variables of your Animation Blueprint (including members of structures).

  • Calling Blueprint 'pure' functions that don't modify state (such as most math functions).

Comments