UDN
Search public documentation

AnimationOverview
Licensees can log in.

Red links require licensee log in.

Interested in the Unreal engine?
Check out the licensing page.

Questions about UDN itself?
Contact the UDN Staff

Animation System Overview

Document Summary: Overiew of the classes and structures used by the Unreal Engine animation system.

Created by James Golding. Updated by Laurent Delayen.

Overview

The Unreal Engine animation system adds motion to rendered objects and entities. Animated objects are called Skeletal Meshes. Unlike Static Meshes (which can only be animated via Matinee), Skeletal Meshes have a set of bones to make up a skeleton. These bones are used to drive the motion of the object and placement of objects on a mesh.

There are two main parts to the animation system - playback of keyframed animation data, and blending of animations together.

Pipeline

The animation system is part of the Unreal Engine pipeline. First, normal animation is processed (blending animations). Inverse Kinematic control is then applied. Next is the physics for the skeleton. The physics subsystem then processes the remaining physics, and the graphics subsystem then renders everything.

Animation-Pipeline.JPG

Workflow

Typically, a programmer and an animator will work together to produce the needed animation content. The animator will set up a skeleton and label bones according to an agreed-upon convention. The programmer will tie it all together based on the pipeline (classes, functions, flags, etc.).

Animated Meshes

In the Unreal Engine, animated meshes are called Skeletal Meshes, as bone-based skeletal animation is the primary mechanism for driving animation for objects in the game. Previously, there was also vertex-based animation.

Characters

Weapons

Vehicles

Animation Blending

Unreal Engine 3 uses the idea of 'blend trees' to blend together multiple sources of animation data. This method allows you to cleanly organise the way in which a number of animations are blended together, and lets you easily add more animations in predicatable ways as you progress.

Blend Tree Overview

Here is a simple animation blend tree:

animtreediagram.gif

Trees are made up of a tree of nodes. There are two main classes of node:

Blend Nodes (Circles) These take a set of children and blend them together in a certain way. The base class for blends is AnimNodeBlendBase.
Data Nodes (Boxes) The leaves of the tree, have no children but actually generate bone transforms.

In this example, the 'Directional Blend' nodes will blend together the directional animation connected to them based on the actors velocity and heading. This will produce a directional walk and run animation. These are then fed into a 'Speed-based' blend, which blends the two children together based on the speed of the Actor. Finally there is a 'Firing-based Blend' which

It is easy to create very specific blend types based on a few basic blend node type defined in Engine.

See AnimationNodes to find out more about the default animation nodes available in the engine.

Basic BlendNode types

AnimNodeBlend

This is a simple blend that combines 2 children together. You can specify the desired weight of the second child, and how long (in seconds) to take to get there.

AnimNodeBlendList

This take a number of child animations. You can specify which one you want to have at full strength (ie a weight of 1.0), and how long to to take to get there.

AnimNodeBlendPerBone

This is the same as AnimNodeBlend, only gives you per-bone control over how the 2 child animations are blended together. This node acts essentially as a per bone mask.

AnimNodeBlendDirectional

This blend node takes 4 child nodes, representing the forward, backward, strafe left and strafe right animations. It look at the Actor that this animation tree is within and blends the children together based on the its current velocity and heading.

Building Blend Trees

Animation trees are built using the AnimTree Editor, which is part of UnrealEd. You can create a new AnimTree using the Generic Browser, and then double-clicking on it will open the AnimTree Editor viewing the new, empty tree.

You can then tell a SkeletalMeshComponent to use your AnimTree in its defaultproperties block:

defaultproperties
{
   Begin Object Class=SkeletalMeshComponent Name=SkeletalMeshComponent
      SkeletalMesh=SkeletalMesh'BigCritter.CritterMesh'
      AnimSets(0)=AnimSet'BigCritter.CritterAnims'
      AnimTreeTemplate=AnimTree'BigCritter.CritterAnimTree'
   End Object
}

It's important that you assign the AnimTree to the AnimTreeTemplate property, and not to Animations. When play begins, the AnimTree referenced by AnimTreeTemplate is copied, and this instance is assigned to Animations, and is the one used during gameplay because it contains actual state.

See AnimationNodes to find out more about the default animation nodes available in the engine.

Animation Playback

AnimSequence

An AnimSequence is a single animation, a collection of keyframes.

AnimSet

An AnimSet is a collection of AnimSequences. They live in packages, and can be seen in the Generic Browser in the same way as materials, meshes etc.

animsetinbrowser.jpg

All AnimSeqeunces in an animation set must have the same number of tracks, and the tracks must refer to the same bones. This should be taken care of for you when you import a PSA file in the AnimSetViewer. See ImportingAnimationsTutorial for more information on the AnimSetViewer and importing animations.

Bone To Track Mapping

Tracks in the AnimSet are related to bones in the skeletal mesh by name. This is because you may want to play the same animation set on different skeletal meshes which do not have exactly the same number or order of bones. For quick lookup the AnimSet caches a set of AnimSetMeshLinkup structures. These are a mapping table between the bones of a particular skeletal mesh and the tracksof the AnimSet.

AnimNodeSequence

This is a subclass of AnimNode that knows how to play back keyframe data stored in AnimSets. It commonly forms the leafs of your blend tree.

The animation sequence you wish to play is specified by name in the AnimNodeSequence. To find the AnimSequence, it will look through the AnimSets array in the SkeletalMeshComponent. The advantage of referencing the animation sequences by name instead of by pointer is that it allows you to use the same tree for completely different meshes/animations. When searching through the AnimSets array, it will start from the end and work backwards until it finds an AnimSet with an AnimSequence with that name. This allows you to override a particular sequence by adding a new AnimSet containing a sequence with the same name later in the array.

AnimNodeSequence properties

bPlaying Set if the animation is currently playing. Unset if the animation is paused
bLooping Set if the animation should loop, and play forever
Rate Play rate
bNoNotifies If set, animation notifies won't be triggered
bShowTimeLineSlider Toggles drag bar to control time position

AnimGroups

When managing a lot of different animations together, there is quickly a need to organize these animations and manage them at a higher level. To help with this, the animation system uses a concept of AnimGroups.

With AnimGroups, it is possible to synchronize a bunch of nodes together, have only the most important node of the group trigger notifications, and adjust the play rate of all these nodes globally. It can be a combination of these options, not all nodes have to be synchronized.

Synchronization

This was done before using a special node called AnimNodeSynch. This has been since integrated into this AnimGroup system. And so it is encouraged to remove the AnimNodeSynch.

The reasoning behind animation synchronization, is to be able to synchronize animations of different lengths together. This is especially useful, for example, for movement cycles. Transitioning between walking and running seemlessly. The idea is to have the animations relatively synchronized. For example left foot down at 0%, and right foot down at 50% of all movement cycles. Now, if we keep the walk and running cycles synchronized together, relatively, we can change the play rate of each depending on the velocity of the character, and transition from either walk cycles seemlessly. The feet will be synchronized.

Notifications

When transitioning between similar animations, there is also the problem of handling notifications. For example foot steps with movement animations. When transitioning between different cycles, and using the weight threshold based system to trigger notifies, you can end up with cases where no notifies are fired at all (or in some cases, several can be triggered at once). What we really want is the most important animation of a group to be in charge of triggering notifies, and this is precisely what AnimGroups are doing!

Group play rate control

Finally, AnimGroups also allow to control the play rate of the animations at a group level. Note that this is in addition to the per anim node rate. So anim nodes can have different/variable rates, and the group rate will scale all animation nodes of that group on top of their individual play rate.

Setup

To create a new group, select the AnimTree node (root node of the blending tree). Expand AnimGroups, and add a new entry. Type in the desired name for your group the in "GroupName" property. The RateScale property is to scale the global play rate of this group.

Then, select the AnimNodeSequence node that you'd like to add to this group. Expand its Group section. You'll find the following properties:

bForceAlwaysSlave Node will be synchronized, but never picked as a master node.
bSynchronize TRUE by default, node will be synchronized. Uncheck if you do no wish this node to be synchronized.
SynchGroupName Name of group this node belongs to. Set it to the same group name that you've created in the AnimTree AnimGroups array.
SynchPosOffset If this animation was not authored relatively synchronized with the others (left foot, right foot inverted), then it's possible to offset the animation to make it match. Offset is relative position, 0.f to 1.f

Under the hood

The grouping system, forces all nodes in the group to be updated in a second pass, after all nodes have been ticked. This is so all nodes have an up to date weight in the blending tree. Then each group will look for 2 masters. One for synchronization, and one for notifications. The reason for having 2 masters is that not all nodes can be synchronized, and not all nodes can trigger notifies. So the leaders in each category are the most relevant nodes (the ones with the highest weight in the tree, able to either synchronize or trigger notifications). Once the master nodes have been picked, all the group nodes are updates. Nodes that need to be synchronized will be, and nodes that need to trigger notifies will also be.

There are also a few useful script functions available in AnimTree to control groups from script code. Adding/removing nodes on the fly, controlling synchronization position, play rate scale, etc.

Root Motion

See the Root Motion page.

Inverse Kinematics (IK)

Physical Animation

For more information on combining physics and animation, see the Physical Animation page.

Useful Console Commands

show bones - shows bones locations used to render skeletal mesh.