How to do it...

To use motion capture data for Humanoid characters, follow these steps:

  1. First we need to create a rig suitable for Unity's Humanoid characters. In Blender, creating such a rig is quite easy. First enable the Rigify add-on and create a new Human (metarig) object from the Armature section.
  2. This rig has almost the same structure as Unity's Humanoid rig, but we need to adjust a few things. First, edit the rig and delete the heel.Lheel.Rheel.02.L, and heel.02.R bones from the feet.
  3. Then delete the palm.01.Lpalm.02.Lpalm.03.Lpalm.04.Lpalm.01.Rpalm.02.Rpalm.03.R, and palm.04.R bones from the hands.
  4. This gives us a proper Unity Humanoid rig. We can also adjust the T-Pose (a Rigify rig is created in a more relaxed T-Pose). This step is not a necessity. Name that rig FinalRig.
  5. Now adjust the bone sizes for your character and skin the character to the rig.
  6. Enter Pose Mode and click on both shoulders. Enable their Y axis rotation (it is locked by default). This step is important for making the final animation.
  7. Import your BVH file (FileImportBVH). You may want to adjust the size of the rig in import settings.
  8. Scale the imported BVH rig to roughly match the size of your character. Name the BVH rig ImportedRig for better clarity.

  1. Now we will create a control rig that we will use to correct any errors. To do so, create an empty object in Blender and name it Hips. Create another empty object and name it HipsTarget. Make sure both objects have exactly the same position and rotation.
  2. Parent HipsTarget to Hips.
  3. To make the objects more visible, set the Display of Hips to Cube and the Display of HipsTarget to Sphere.
  4. A pair of those empties is our bone node—we will create one for each bone of the character:
Bone node—a pair of two empties
  1. Select the Hips object and add the Copy Transforms constraint to it.
  2. Select the ImportedRig as the Target and its Hips bone as the Bone.
  3. Repeat steps 9-14 for every bone of the FinalRig (you can omit the fingers as not many motion capture files have data for fingers anyway). After completing this process, you should have a list of empties reflecting the structure of the FinalRig. It should look similar to the following: 
    • Hips (and HipsTarget parented to it)
    • Spine (and SpineTarget parented to it)
    • Chest (and ChestTarget parented to it)
    • Neck (and NeckTarget parented to it)
    • Head (and HeadTarget parented to it)
    • Shoulder.L (and ShoulderTarget.L parented to it)
    • Shoulder.R (and ShoulderTarget.R parented to it)
    • LegUp.L (and LegUpTarget.L parented to it)
    • LegUp.R (and LegUpTarget.R parented to it)
    • Leg.L (and LegTarget.L parented to it)
    • Leg.R (and LegTarget.R parented to it)
    • Foot.L (and FootTarget.L parented to it)
    • Foot.R (and FootTarget.R parented to it)
    • ArmUp.L (and ArmUpTarget.L parented to it)
    • ArmUp.R (and ArmUpTarget.R parented to it)
    • Arm.L (and ArmTarget.L parented to it)
    • Arm.R (and ArmTarget.R parented to it)
    • Hand.L (and HandTarget.L parented to it)
    • Hand.R (and HandTarget.R parented to it)
  4. Sometimes our ImportedRig has a different structure, for instance it may have more spine bones (three or more). In such case, we should choose the most suitable bone in the Copy Transform constraints or add two Copy Rotation constraints and interpolate the final rotation of two neighboring bones by setting the Influence slider:
Control rig with Copy Transform constraints
  1. Now we need to set the IK for feet. Select the FinalRig and go to Edit Mode.
  2. Copy both foot bones and change their names to footTarget.L and footTarget.R.
  3. Remove their parents and unselect the Deform option (they shouldn't deform the mesh).

  1. Go to Pose Mode.
  2. Select the shin.L bone and add an Inverse Kinematics constraint. Set the Chain Length to 2 and choose the FinalRig as Target, and footTarget.L as the Bone.
  3. Select the foot.L bone and add a Copy Rotation constraint to it. Choose the FinalRig as the Target, and the footTarget.L as the Bone.
  4. Repeat steps 21 and 22 for the right leg.
  5. Select the hips bone and add the Copy Rotation and Copy Location constraints to it. In both constraints, set the Target to HipsTarget empty.
  6. Select the Offset option in the Copy Location constraint and move the hips bone (in Pose Mode) to roughly match the position of the HipsTarget empty in the scene.
  7. Select the footTarget.L bone. Add the Copy Location and Copy Rotation constraints to it. In both constraints, choose the FootTarget.L empty as the Target.
  8. Select the Offset option in the Copy Location constraint and move the footTarget.L bone (in Pose Mode) to roughly match the position of the footTarget.L empty in the scene.
  9. Repeat steps 26 and 27 for the right foot target.
  10. Add a Copy Rotation constraint to every other bone (including those with the Inverse Kinematics constraint). Set the Target for each such constraint to a corresponding empty (for the shin.L bone, choose the LegTarget.L empty, and so on).
  11. You should see the motion of the ImportRig being transferred to the FinalRig. Additionally, you can move the hips bone and the footTarget.L and footTarget.R bones to adjust the animation.
  12. If you see any errors on the mesh, especially if the limbs of the character are rotated in a weird way, you can rotate the target empties to fix this.
  13. You can also rotate the target empties to change the overall pose of the character easily.
  14. To finish the retargeting process, save your file as a new one. Select all the bones in the FinalRig (in Pose Mode), press the space bar, type Bake Action, and press Enter.
  15. In the Bake Action window, choose Visual Keying and Clear Constraints. You can also provide a name for the newly created action. If you click on OK, all constraints will be removed and the final animation will be baked.
  16. Remember to select the small F symbol near this action in the Action Editor (this will save the data even if the rig doesn't use it).

  1. Remove all the empties and the ImportedRig (you may also need to remove its action manually). Save the file.
  2. Import the file into Unity and set the rig to Humanoid. The animation should work as intended. You may also choose to export the file to FBX first. If you experience any problems, try with the 6.1 version of the FBX format as it may help:
FinalRig on the left and ImportedRig and the empties (control rig) on the right
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.19.185