Notifications
Article
Retargeting animations with Blender 2.80
Published 2 months ago
1.8 K
4
Introduction
This is a step-by-step guide to retargeting animations from one rig to another in Blender 2.80. This approach doesn't require any add-ons to work. I use this method to retarget motion capture data to my characters for further use in Unity.

The concept in a nutshell

This concept is composed of:
  • the TARGET RIG - the one you'd like to retarget animation to (the one, you will be finally using),
  • the SOURCE RIG - the one you'd like to retarget animations from (a motion-capture BVH file for example)
  • the META RIG - the one with which you will transfer the motions from the TARGET RIG to the SOURCE RIG.
The META RIG is the most important part. It's created with empties. For every bone in the TARGET RIG, there is a pair of two empty objects, let's call them BONE FOLLOWER and BONE TARGET. BONE TARGET should be parented to BONE FOLLOWER. They should have the same position and rotation (local rotation and position of BONE TARGET should be 0).
For convenience, I've used a box empty for BONE FOLLOWER and a sphere empty for BONE TARGET.
  • The BONE FOLLOWER follows a given bone from the SOURCE RIG. It has to copy the bone's location and rotation by using the Copy Location and the Copy Rotation object constraints (with Space set to World Space -> World Space).
  • The BONE TARGET is followed by a corresponding bone from the TARGET RIG. The bone has to copy the location and rotation of the BONE TARGET empty by using the Copy Location and the Copy Rotation bone constraints (with Space set to World Space -> World Space).
This way the given bone from the TARGET RIG follows the location and the rotation of the corresponding bone from the SOURCE RIG. Additionally, you have full control of the final rotation of the TARGET RIG's bone by rotating the BONE TARGET empty.
You may ask why we cannot simply add the Copy Rotation and Copy Location bone constraints to the bone from the TARGET RIG and set the corresponding bone from the SOURCE RIG as the target? There is a huge problem with this as in most cases the bone-roll of the bones doesn't match and you get weird/unpredictable results. Using a META RIG allows for further adjustments. You can correct any rotation errors by rotating the BONE TARGET empty in its local coordinates.
Now, let's retarget an animation step-by-step.

Step 1 - the TARGET RIG

First, you need to have a character with your TARGET RIG - the one you'd like to use (in the game for example). For the purpose of this article, I will be using a simple cartoony teddy bear. You can download it here (use it as you please):
The rig looks like this:
In my case, the rig has a standard (simplified - no fingers) humanoid structure:

Step 2 - the SOURCE RIG

You need to have the SOURCE RIG with an animation (an Action in Blender). I use an imported BVH file in this example. To import a BVH, you should go to File -> Import -> Motion Capture (.bvh) in Blender.
IMPORTANT NOTE: When you import the SOURCE RIG, scale it in the object mode to roughly match the hips height to your TARGET RIG's hips height. That should greatly reduce feet sliding.
Here you can find a file with the BVH already imported:

Step 3 - the FOLLOWER and the TARGET pair

We are going to create a template for all our META RIG "bones". First, make sure you have a tidy workspace. Rename the imported BVH to SOURCE RIG and your final armature to TARGET RIG, if needed.
Create a box empty. Go to Add -> Empty -> Cube. In the empty properties panel, edit the size of the empty to something more suitable. I use 0.05m. Change the empty's name to Hips (we are going to start with the Hips bone). Add the Copy Location and Copy Rotation object constraints to the Hips object.
Now create another empty - a sphere. Go to Add -> Empty -> Sphere. Again edit the size of the empty in its properties panel. I use 0.04m (slightly smaller than the box empty). Rename the sphere empty to HipsT (T stands for TARGET). Make sure both empties are in the exact same spot and have the same rotation (you can select both of them and press ALT+G to reset their location and press ALT+R to reset their rotation).
Parent the HipsT object to Hips object. To do this first select the HipsT object (the sphere empty), then shift-select the Hips object (the cube empty), press CTRL+T and choose the Object option.
You should have a pair of parented empty objects that will serve as a template for all the other needed "bones".

Step 4 - creating the META RIG

Now we need to select both empties (Hips and HipsT) and duplicate them for every bone in the TARGET RIG. Remember to give meaningful names to all the duplicates. The names should correspond to the names of the bones in the TARGET RIG. I use the Bone and BoneT naming convention for the FOLLOWER empty and the TARGET empty to make things simple.
To make the workspace cleaner, put all the FOLLOWER empties in the BoneFollowers collection and all the TARGET empties in the Targets collection. This way it will be easier to control the empties' visibility later on.
In this example, the hierarchy of the META RIG looks like this:
  • Hips
  • HipsT
  • Spine1
  • Spine1T
  • Spine2
  • Spine2T
  • Chest
  • ChestT
  • Neck
  • NeckT
  • Head
  • HeadT
  • ShoulderL
  • ShoulderLT
  • ArmL
  • ArmLT
  • ForeArmL
  • ForeArmLT
  • HandL
  • HandLT
  • ShoulderR
  • ShoulderRT
  • ArmR
  • ArmRT
  • ForeArmR
  • ForeArmRT
  • HandR
  • HandRT
  • UpLegL
  • UpLegLT
  • LowLegL
  • LowLegLT
  • FootL
  • FootLT
  • UpLegR
  • UpLegRT
  • LowLegR
  • LowLegRT
  • FootR
  • FootRT
You can find the completed rig here:

Step 5 - connecting the META RIG to the SOURCE RIG

To connect the META RIG to the SOURCE RIG's bones, you have to fill in the target fields of the Copy Location and the Copy Rotation object constraints for every FOLLOWER empty. Start with the Hips object. Select it, go to the Object Constraints tab and select the SOURCE RIG as the target, then select the corresponding bone from the SOURCE RIG.
You have to repeat this process for every FOLLOWER empty. Your finished result should look like this:
Your SOURCE RIG's structure may (and most probably will) differ from the TARGET RIG's hierarchy. For instance, you may have 5 spine bones in the SOURCE RIG and only 4 or even fewer spine bones in the TARGET RIG. For now, simply target the bones with the most influence on the final pose. You will be able to adjust this later in the final step.
You can find the connected META RIG here:

Step 6 - connecting the TARGET RIG to the META RIG

Now we have to connect all the TARGET RIG's bones to corresponding TARGET empties. Let's do it for the Hips bone first. Select the Hips bone (int the Pose Mode) from the TARGET RIG. Add the Copy Rotation and the Copy Location bone constraint from the Bone Constraints tab and set the HipsT empty as the target. The TARGET RIG should start following the Hips of the SOURCE RIG when you play the animation.

We have to repeat this step for all the remaining bones. Here are some tips to make the job a bit easier:
  • You don't have to use the Copy Location bone constraint for the remaining bones (in the standard humanoid setup). The Copy Rotation constraint is enough.
  • When you click on the Target field in the Copy Rotation constraint you can start typing the name of the object to quickly find the one you're looking for.
  • You can also hide the BoneFollowers collection and the SOURCE RIG and use the object picker of the Copy Rotation's Target field.
When you finish picking targets for all the Copy Rotation bone constraints, your TARGET RIG should follow all the movements of your SOURCE RIG. You can still have some rotation errors, that we will fix next.
You can find the retargeted animation here (with errors):

Step 7 - correcting rotation errors

Your retargeted animation will most probably have some rotation errors due to the differences between SOURCE and TARGET rigs' bone rolls. To correct such errors, simply select the TARGET empties corresponding to problematic bones and rotate them in their local axes. Remember that you can easily rotate a given TARGET empty by pressing R on the keyboard followed by double-tapping X, Y or Z.
In my example, the feet have rotation errors. I have to select the FootRT and the FootLT empty and rotate them to correct the problem. There is no silver bullet here. You have to visually match the rotation.
Useful TIP: Start with rotating the empty in only one local axis. Hit R on the keyboard and double-tap any chosen axis (XX, YY or ZZ). Start rotating and observe if the rotation helps. If not - hit escape, and change the axis. If the rotation seems to help, you can enter 90, 180 or 270 from the keyboard (the rotation is off by a multitude of 90 degrees in most cases).
In my case, I had to rotate the FootRT empty by 180 degrees in local Z-axis (R -> ZZ -> 180 -> ENTER) and 90 degrees on the local Y-axis (R -> YY -> 90- > ENTER). That looked almost fine (see below).
Rotating an additional 20 degrees in the local Y-axis and -15 degrees in the local X-axis did the trick. Now there are no visible rotation errors on the right foot.
Repeat the process on every bone with incorrect rotation.
You can find the retargeted animation with corrected rotations here:

Step 7 - tips for finalizing the animation

Now the animation from the SOURCE RIG is retargeted to the TARGET RIG, but we can do a few additional adjustments:
  • You can move and rotate the SOURCE RIG in the Object Mode to reposition the animation of the TARGET RIG. It is very useful for dealing with motion-capture data for video games (where you often have to start the animation in the world origin).
  • If you observe feet sliding, try scaling the SOURCE RIG.
  • If you have more bones in the SOURCE RIG than the TARGET RIG, you can add more than one Copy Rotation constrains on the FOLLOWER empty and adjust their Influence slider (set them to 0.5 and 0.5 for instance). This way, you will blend between the bones' poses. You don't have to do it if the final motion satisfies your needs (frankly speaking, I almost never use it).
  • You can also change the appearance of the final animation by rotating the TARGET empties, similar to how you do it for correcting the rotations. This way you can offset the arms pose, straighten the spine or even completely change the feel of the whole animation. One great thing about this technique is that you adjust the world space rotation of every bone, so rotating a parent bone doesn't change the world space rotation of its child-bones. Here I've made the teddy bear a little more confident by rotating Spine1T, Spine2T, ChestT and HeadT empties:

Step 8 - baking the animation

You will most probably need to bake the retargeted animation at some point. To bake the animation:
  1. Make sure you are in the Pose Mode of your TARGET RIG.
  2. Select all the bones.
  3. Press F3 (or SPACEBAR depending on your Blender settings) and type Bake.
  4. Choose the Bake Action option.
  5. Select the Only Selected Bones, Visual Keying and Clear Constraints checkboxes.
  6. Make sure the Pose option is highlighted in the Bake Data section.
  7. Set your desired animation length (Start Frame and End Frame) and Frame Step.
  8. Hit the OK button.

TIPS

Here's a bunch of additional tips and tricks:
  • Baking the animation clears all the bone constraints on your TARGET RIG. But you can make a copy of the RIG prior to baking and bake the animation on the copy of your TARGET RIG.
  • It's good to have work on two files:
  • one for retargeting the animation - let's call it EDIT
  • one with clean TARGET RIG that you can import baked actions into - let's call it FINAL. To import such an action, you can select the copy of your TARGET RIG in the EDIT file, press CTRL+C - that copies the rig and its Action to clipboard. Open the FINAL file, and press CTRL+V - that will paste your TARGET RIG copy from the clipboard into the FINAL file. Now you can enter the Dope Sheet editor, change it to Action Editor and press the shield icon on the newly imported Action. This way, the Action will be preserved in the FINAL file even if you delete your TARGET RIG copy.
  • You have to get through the process of creating the META RIG only once for every SOURCE RIG - TARGET RIG pair. If you have multiple BVH takes (motion-capture recordings) but your BVH rig is the same, you can import them to your EDIT file. Then you have to select your SOURCE RIG, open the Action Editor and change its action to the one you have just imported. This way you can quite quickly retarget new animations.
  • You can also use Inverse Kinematics bone constraints on the feet of your TARGET RIG, to eliminate feet sliding. You can set the FootLT and FootRT as the targets of the Inverse Kinematics constraint. See Blender's official Inverse Kinematics tutorials for further details.
  • You can animate the rotation of the TARGET empties to achieve interesting results. It works similar to additive animation.

Final word

I hope this method will help you retarget your motion-capture data in Blender (I had a hard time figuring this all out). If you need any help, feel free to pm me or leave a comment. Also subscribe to my youtube channel, if you're interested in any further tutorials/tips and tricks.
Maciej Szcześnik
Independent Game Developer - Designer
3
Comments
Independent Game Developer
dx_houleThis guide was amazingly well prepared and works perfectly with Blender 2.8. Thank you very much! :)
Thanks! I'm glad I could help. I will create more guides soon as I progress with my game :).
0
Independent Game Developer
dx_houleThe copy rotation constraint for Blender 2.81 has changed and I can't get the target rig to move properly, no matter what the settings or how much I rotate the target empties. Has anyone found a way to fix this?
I will look into this then.
0
d
dx_houle
2 months ago
The copy rotation constraint for Blender 2.81 has changed and I can't get the target rig to move properly, no matter what the settings or how much I rotate the target empties. Has anyone found a way to fix this?
0
d
dx_houle
2 months ago
This guide was amazingly well prepared and works perfectly with Blender 2.8. Thank you very much! :)
0