April 10, 2014

Intro to Animation Retargeting in UE4

By Laurent Delayen

We’re going to briefly talk about what Animation retargeting is, and how to use it.

Animation Retargeting is the ability to play an animation made for a specific character, and play it on another character of different proportions.

How does it work?

All animation assets are bound to a Skeleton, and the Skeleton is where we define how each bone will be retargeted. This is very important: retargeting will only work between Skeletal Meshes sharing the same Skeleton Asset!

We only retarget the bone’s translation component. The bone’s rotation always comes from the animation data.

We have 3 different settings for bone translation retargeting:

  • Skeleton: Bone Translation comes from the Target Skeletal Mesh’s bind pose.
  • Animation: Bone Translation comes from the animation data, unchanged.
  • Animation Scale: Bone translation comes from the animation data, but its length is scaled by the Skeleton’s proportions. This is the ratio between the bone length of the Target Skeletal Mesh (the skeleton the animation is being played on), and the Source Skeletal Mesh (the skeleton the animation was authored for).

You set those settings on the Skeleton Tree window in Personna:

Skeleton Tree

Typically you’ll want to use those settings for bipeds:

  • Root Bone, IK Bones, weapon bones and any kind of markers to use “Animation”, so they come out unchanged.
  • Pelvis will use “AnimationScaled”, so it sits at the right height, and is still animated. And any other bone you want the translation to be animated AND retargeted.
  • All other bones will use “Skeleton.” They will use the fixed translation from the Target skeleton (The skeletal mesh the animation is being played on).

In the “Show” menu from the viewport, you can check “NonRetargeted Animation” and “Bones” to compare the original with the retargeted animation.

NonRetargeted Animation

This visualization works on single assets but also on Animation Blueprints.

Original Animation | Retargeted Animation

How are end effectors handled with retargeting? For example, do taller characters run faster, can they still hold the same props?

There is no automatic work happening there. It is up to the user to decide what it wants to do.

What we typically do is have a separate chain of bones following the hands in the original animation, called “Hand IK Bones”. We retarget the body and arms, but not those “Hand IK Bones”, so they remain identical after retargeting. This allows us to have characters of different proportions manipulating the same props (for example, reloading a rifle).

Having a separate chain of bones allows us to switch smoothly between FK and IK easily when we want to (We would want the Hand IK ON when reloading the weapon, and OFF when reaching for a magazine in a pocket).

The system that we use internally is actually a little bit more complex than that, as we sometimes only want the left hand to be IK from the right hand, while we want the right hand to use its FK position, but IK rotation. That’s something we can discuss in more detail in another blog post! But you get the idea that such system is flexible and really allows you to make it as simple or as complex as you’d like.

Feet are sometimes handled that way, sometimes not. Again, having a chain of bones allows us to switch between FK and IK at any point very easily. When stepping on very precise props, you’d want to turn on the IK; when you’re just running around, you’d want to use the FK, so you don’t end up with a bow legged character (or the opposite).

How does this affect performance?

There is no significant difference of performance between using retargeted and non-retargeted animations. The benefit of using animation retargeting is increasing the number of unique characters without having to create an entirely new set of matching animations. So this could seriously cut down on the animation memory budget.

Can we mix and match animations made for different characters?

Yes, absolutely! We call a “Retarget Source” the bind pose of a Skeletal Mesh that was used to author an animation. By default the Skeleton asset will store a single default “Retarget Source” (The original Skeletal Mesh it was created from).

But let’s say that you have a tall character and a short character. You want to be able to tell which animation was authored with the short character, and which animation was authored with the tall one. That way the engine knows how to retarget those animations onto the target skeletal mesh.

In order to do this, Personna has a “Retarget Source Manager” in the Skeleton Tab. Right clicking allows you to add a new “Retarget Source.”

Retarget Source

Here you will store and manage all the “Retarget Sources” used to import animations authored on characters from different proportions.

Once you have imported such animation, you can go into its properties to set which “Retarget Source” it was authored on.

Animation Asset Details

Note that you only need to worry about this if you’re going to mix and match animations authored on different proportion characters. If all of your source data comes from a single Skeletal Mesh, the Skeleton asset will store that “Retarget Source” as the default.

Hope this gives you a quick overview on how to retarget and share animations between different characters! If you have any questions or just want to chat more, head over to the forums!