UDN
Search public documentation

AnimationMirroring
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 Mirroring

Document Summary: How to set up and use the Animation Mirroring feature in the Unreal Engine.

Document Changelog: Created by James Golding.

Overview

In games it is common to need animations that are mirror images of each other. For example, you may need both a 'look to the left' and a 'look to the right' version of the animation. Though it is possible to create both of these animations externally and bring them into the engine, sometimes it is desirable to generate these on the fly, as well as mirroring dynamic blends of animations. Note that a skeleton must be symmetric in order to use mirroring.

Setting Up The SkeletalMesh

Before you can use mirroring, you must set up certain information in the SkeletalMesh. If you open the mesh in the AnimSetViewer, you can find the mirroring settings under the 'Mesh' tab on the right. The first things to set up is SkelMirrorAxis - the axis over which to mirror your character. Note that this is in 'mesh' space - that is, the reference frame that the mesh was authored in in the 3D package, before RotOrigin is applied. The next thing to set is the SkelMirrorFlipAxis. When you mirror a bone transform, you need to flip one of the axes in order for the bone not to be turned `inside out'. Which axis is flipped depends on how your skeleton is constructed, and this setting lets you set the default axis to use. You can however over-ride this default per-bone in the SkelMirrorTable (more on that in a moment).

Here are a couple of examples of using the flip axis. In the first one, the bone 88 is mapped to bone 65 - mirrored, and then the X-Axis is flipped:

mirror_shoulder.jpg

In this example, bone 90 is mapped to bone 86 - mirrored and then the X-Axis flipped.

mirror_feet.jpg

The most time-consuming part of setting up mirroring for a skeletal mesh is getting the SkelMirrorTable correct. This table is a mapping of where each bone should get its animation from when being mirrored. In the table, the source for the right knee would be the left knee for example, and the source for the spine would just be the spine, as this bone is along the center-line. The AnimSetViewer contains a tool for attempting to create this mapping table automatically. Under the `Mesh' menu, choose `Auto-build Mirror Table'. This will create the table, and try and match bones that are in corresponding positions across the mirror plane when in the reference pose. Note - you must set the SkelMirrorAxis setting before running this tool. The tool normally works quite well for the majority of the body, including legs, arms, fingers etc. It can have problems if you have multiple bones in the same location, or when there are many bones close together (like when using many facial bones). Once the table is created, you can see how things are working by pressing the `View Mirrored' button on the AnimSetViewer toolbar:

mirror_button.jpg

You will usually have to do some fix-up work on the auto-generated table to get things to look correct. Under the `Mesh' tab, when you expand the SkelMirrorTable section you should see an entry for each bone in the skeleton. Inside each entry, it shows you the number of the bone it is getting its transform from. These must always form pairs - if the source of bone 88 is bone 65, then the source for bone 65 must be 88. To find which index corresponds to which bone, you can either turn on bone names in the 3D viewport, or use the `Copy Bone Names To Clipboard' option in the `Mesh' menu and paste a listing into a text editor. You can also adjust the BoneFlipAxis per bone to override the SkelMirrorFlipAxis default.

Using Mirroring In An AnimTree

Once a SkeletalMesh is set up to use mirroring, it is very straightforward to use in an AnimTree. There is a special AnimNode type called AnimNodeMirror which has one input and one output. If you insert one of these in the tree, it will mirror what ever the input animation blend is. In this way you can mirror an individual animation or a blend of animations, and blend between mirrored and un-mirrored animations, making transitions much smoother.

mirror_node.jpg

The bEnableMirroring flag in the AnimNode allows you to toggle the mirroring behaviour on and off. Note that mirroring an animation is quite costly, so try to use as few AnimNodeMirrors as possible.