Creating an animation rig in Blender

From OniGalore
Jump to navigation Jump to search


This tutorial shows you how to create the animation rig for Blender (made by geyser) from scratch, with some improvements.

The purpose of this rig is to give us much better tools to animate, compared to our previous process in Softimage XSI by EdT, which allowed us to animate exclusively with Forward Kinematics. While FK may work for simple, short animations done on characters with a small amount of bones, it does not work well for Oni characters and animations, as it's too labor-intensive and inefficient.

If you are looking for information on how to use the rig, please refer to the article on that available HERE.

Prerequisite tutorials

I highly recommend watching the tutorials below if you feel you're lacking knowledge in any of these subjects:

General Blender basics:

Blender Character Rigging overview showing that you can create a Rigify rig in less than a minute at 5:43, and also rig a character while at it:

Practical and intuitive explanation of what Inverse and Forward Kinematics (IK/FK) are - this is explained in Maya, but same principles apply in every 3D editing program including Blender:

Basics of using Rigify:

Rigify Bone Groups and Layers:

Changing Rigify Custom Shapes and Widgets:

Blender custom properties and drivers (drivers in the rig described here are used to set the influence of its controllers' bone constraints through the Pose1 and Pose2 bone locations):

Tracking constraint tutorials

These explain constraints like Damped Track which are used by Rigify – you can skip this if you want, but it might give you a better idea of how Rigify's MCH (Mechanical) layers work, or come in handy in the distant future; other than that, you don't need to know them to animate for Oni:

Things to know before starting

There are several things worth knowing before you start creating the rig.

Tools and relevant tutorials

Screenshot showing Cmder's capabilities within the context of modding Oni
  • Current version of OniSplit. This is the tool needed to import and export assets out of Oni. DO NOT USE OniSplit GUI or Vago for importing Oni assets into Blender - neither of these weren't updated in a long time, and thus they don't support OniSplit's v0.9.99.2 -blender option. You can still use them for other purposes though, such as sounds and converting .oni files to XMLs, etc.
  • Cmder (Windows only) - because OniSplit is a command line tool, it is highly recommended to get any upgrade to Windows' Command Prompt. As shown in the screenshot on the right, Cmder allows you to start it from the context menu in any selected folder, and it also remembers your most recently used commands, vastly improving your workflow when you're forced to use any command line tools.
  • Rigify - it's a plugin for Blender designed to automate a lot of rigging work. The rig described here is generated using Rigify.
  • Oni-Blender tutorial by EdT. Please read this in entirety to know likely-to-happen issues and refer to this as your guide for OniSplit commands relating to Blender.
  • Brief overview on creating TRAMs by EdT - while this was written with XSI in mind, this is still relevant as the process for preparing the XML files for Oni is still the same. Also the next post in that thread, called Brief walk through on modifying a TRAM, is an example of that overview put into practice.

Rotation order issue between Oni and Blender

Please refer to THIS.

Broken alpha transparency and textures on animated models

Please refer to THIS.

Overview of the rig

Here is an overview of how the rig works: As stated before, our previous animating process was limited to FK only, which is inefficient for Oni. So instead we desperately needed an IK/FK capable rig, to which we would be able to snap a character, so we could animate him/her.

At the same time, the rig would have to be capable of the opposite thing - snapping itself to the animated character. That's because most often the way we start out with making a new animation is copying the first or last frame of the preceeding animation. This functionality has been implemented, and is called Pose Matching. The way it works is simple - it uses bone constraints in rig controller bones targeting the character model in order to snap the rig to the model.

The rig uploaded on Oni Mod Depot contains three Konokos by default: One T-Posed Konoko and two animated ones, all stored in their own collections. The T-Posed Konoko is there because it was easiest to build the rig off a T-Pose, while the remaining two ones, stored in Pose 1 and Pose 2 collections, is where you are supposed to store your animated characters, to which you can Pose Match.

Because Oni does not store its animations in form of an armature, but rather as locations and rotations of 19 objects organized in a parent-child relationship, this forces us to use the earlier mentioned object and bone constraints. This is also creates a big problem: in order to animate, rotation and location data from the 19 character body parts have to be transformed onto the rig, and then the body parts have to be constrained to the rig. Once you are done animating and you want to export your animation, you have to do the reverse: transform the animation from the rig onto the 19 body parts, and then disable the constraints. This is quite inconvenient, because all of the constraints (and there's a lot of them) in both the body parts and rig have to be turned on and off.

The general workflow of making animations using this rig is the following, assuming you want to make a single animation (i.e. you don't want to make a throw animation):

  1. Open up a Blender scene containing the rig.
  2. Delete either the model in Pose1 or Pose2.
  3. (OPTIONAL) Assuming you want to animate a different character, delete the T-posed model.
    1. Import your desired character with textures using -noanim.
  4. Import the animation you are using as a starting point.
    1. If you did point 3, apply the textures on the animated model.
  5. Using the RigBoneConstraintTargetSetter script available HERE, set the targets of the rig's bone constraints to be the body parts of the animation you've imported.
  6. Using the Pose Matching functionality, constrain the rig to the imported animation (Set the IK-FK sliders on rig limbs to 1, as Pose Matching works only through FK controllers)
  7. For each frame that you want to remain in your animation, while having all the bones selected (or the ones you want), press Ctrl+A, select Apply Visual Transform to Pose and keyframe it.
  8. Disable bone constraints on the rig using the BoneConstraintEnabler script available HERE.
  9. Make your animation.
  10. Once your animation is ready, use the Visual Transformer script available HERE to bake the rig keyframes into the character model.
  11. Using the ObjectConstraintEnabler script available HERE, disable the object constraints on the character model. The character model should now be animated and have the needed rotations and locations.
  12. Export the animation as a DAE.

Importing animations and preparing the Blender scene

The actual tutorial starts here.

For detailed explanation of the required OniSplit commands, please refer to the Oni-Blender Tutorial by EdT listed in the Tools and relevant tutorials.

Expected result by the end of this header
  1. Using OniSplit, export any character you want as a DAE (-extract:dae) using -noanim (T-Pose) and -blender arguments.
    1. As per EdT's Oni-Blender Tutorial, you should get AnimationDaeWriter: custom axis conversion in OniSplit output if you've used the -blender argument. If you didn't get that on the output, it means something most likely went wrong and you won't be able to import the model into Blender (or you will be able to import it but it will be wrong).
    2. Assuming you wanted a textured model and thus you've exported an ONCC, you should now get a DAE file and an images folder containing the textures for it.
  2. Using OniSplit, export any two animations as an XML (-extract:xml) using -anim-body (lets you specify the character you want) and -blender arguments.
    1. You should get one DAE and an XML file for each animation, totalling four files.
  3. Open up Blender and set your scene's frame rate to 60 FPS. If you don't, the keyframes of the imported animations will get tightened up together, because Blender's default scene framerate is 24 FPS.
  4. Import the -noanim model into Blender first (MAKE SURE YOU CHECK THE Import Unit BOX, otherwise you will import the model with arbitrary units which will break everything and will be basically unadjustable later)
  5. Import the animations into Blender (ALSO MAKE SURE YOU CHECK THE Import Unit BOX EACH TIME)
  6. At this point the -noanim/T-posed model in the scene should have no suffix in its body part names, while the animated models should have .001 and .002 suffixes. This is intended; the T-posed model will serve for building the metarig and editing the rig once it's generated, while the animated models are needed for pose matching purposes, where the suffixes are useful for setting up the bone constraints.
  7. Create three new collections in the Outliner, name them T-pose, Pose 1 and Pose 2. These three collections allow you to quickly hide the respective models from the Viewport using the eye icon in the Outliner.
    1. Move the T-Posed model to T-pose, and move .001 and .002 animated models to Pose 1 and Pose 2 collections respectively.
  8. If you've imported the textured model, apply textures to the animated models and fix the alpha transparency issue.
  9. At this point, your scene should look as shown in the screenshot on the right.
  10. You can hide the Pose 1 and Pose 2 collections - they won't be changed in this tutorial anymore.

Adjusting T-posed model's Z location

At this moment the T-posed model is sunk to the ground. That's because the pelvis location is set to 0,0,0. All of the animations in Oni have their heights adjusted (through the <Height> tags) so that the pelvis is roughly at Z ~ 0.9, so that the characters appear standing on the floor instead of, again, sinking into it. For this reason, we want to adjust the position of the pelvis so that the feet soles are aligned with the floor.

Expected result by the end of this header
  1. Adjust the Z position of the T-posed model's Pelvis in one of the two ways:
    1. Simply switch to Front Ortographic view (Num 1) and move the Pelvis along the Z axis so that the feet soles are roughly aligned with the floor. This will work, but if you want 100% accuracy, use the method below.
    2. The 3D Cursor snapping method:
      1. Select one of the feet in Object mode.
      2. Switch to Edit mode.
      3. Select one of the lowest-reaching vertices on the foot and Snap Cursor to Active. (Shift + S, 3)
      4. Switch back to object mode.
      5. Select the Pelvis.
      6. Snap Selection to Cursor. (Shift+S, 8)
      7. Set the X and Y locations of the pelvis to 0.
      8. Invert the Z location of the pelvis.
      9. The pelvis should be now at Z ~ 0.9 with feet soles perfectly aligned with the floor.
  2. At this point, your scene should look as shown in the screenshot on the right.

Creating the Rigify metarig and adding limb flexion

This part describes how to create a Rigify metarig and how to adjust it so that it matches the T-posed model body parts.

  1. Before you proceed to create the rig, you need to add small rotations to the limbs, which will allow Rigify to know in which direction the elbows and knees are going to bend. Otherwise, the rig will not function properly.
    1. Add the following Z rotations to the respective body parts in accordance with the list below:
Z rotation Bones
  • right_thigh
  • left_thigh
  • right_calf
  • left_calf
  • right_wrist
  • left_wrist
  • right_biceps
  • left_biceps
  • right_handfist
  • left_handfist
  • right_foot
  • left_foot
  1. Enable Rigify in Blender if you haven't already - you can do that by going to Edit / Preferences / Addons and looking it up, as Rigify comes with by Blender by default.
  2. Add a Basic Human Metarig to the scene. ( Add Menu / Armature / Basic / Basic Human (Meta-Rig) )
    1. Scale the rig by 10 or so that it's roughly the size of the character.
    2. Apply the scale. ( Object / Apply / Scale )
  3. Go to Metarig's Object Data Properties tab and:
    1. Open Viewport Display,
    2. Check In Front box to make the metarig easier to select when your Viewport is in Solid or Material Preview shading modes,
    3. Check the Axes box to see the local axes of each bones - this makes their rolls easier to understand.
  4. Remove the following bones from the Metarig:
  • pelvis.L
  • pelvis.R
  • breast.L
  • breast.R
  • spine.005
  • spine.006
  1. Go to Edit mode, select Bone Properties tab and change the Connected box of the following Metarig's bones accordingly to the below table:
Bone Connected
spine.003 Disable
spine.004 Enable
shoulder.l Enable
shoulder.r Enable
  1. The default Rigify bone layer order is highly unergonomic. For this reason, reassign the following bones to bone layers in accordance with the table below. You can reassign bones' bone layers by selecting them and pressing M. Make sure you have enabled User Tooltips in Preferences / Interface - that way when you move your cursor over the layer box, a tooltip will display the layer number.
Bones Bone layer
  • spine
  • spine.001
  • spine.002
  • spine.003
  • spine.004
  • shoulder.l
  • shoulder.r
  • upper_arm.L
  • forearm.L
  • hand.L
  • upper_arm.R
  • forearm.R
  • hand.R
  • thigh.L
  • shin.L
  • foot.L
  • toe.L
  • heel.02.L
  • thigh.R
  • shin.R
  • foot.R
  • toe.R
  • heel.02.R
  1. Go to Pose mode, select Bone Properties tab and open the Rigify Type box.
  2. Set Limb Segments and B-Bone Segments to 1 on the bones listed below. Because Oni uses rigid body parts, Limb Segments and Bendy bones are not needed.
  • upper_arm.L
  • upper_arm.R
  • thigh.L
  • thigh.R
  1. Disable Assign Tweak Layers checkbox on the bones listed below.
  • upper_arm.L
  • upper_arm.R
  • thigh.L
  • thigh.R
  • spine
  1. Remove rig type on the spine.004 bone.
  2. Set rig type on spine.003 bone to spines.super_head.
  3. Enable the Connect chain checkbox on the spine.003 bone.
  4. Disable the Widget checkbox on shoulder.L and shoulder.R bones.
  5. Set pivot_position on the spine bone to 1.
  6. Enable the Custom Pivot Control checkbox on the spine bone.
  7. Assign Tweak Layer of spine.003 to 9.
  8. Assign FK layers for the following bones in accordance with the table below:
Bones Bone layer
  • spine
  • spine.003
upper_arm.L 1
upper_arm.R 17
thigh.L 5
thigh.R 21
  1. Now you need to adjust metarig's bones so that they match up with character body parts. In order to reduce the amount of needed work, switch to Edit Mode and check the X-Axis Mirror either in Options or the Tool tab.
  2. Switch to Object mode and using the Snapping Cursor to Active, and Snapping Selection to Cursor in the Snap menu (Shift + S), keep snapping cursor to model's body parts, selecting the Metarig, switching to Edit mode, selecting the appropriate bone and snapping it to 3D Cursor. I believe it is intuitive which bones should be snapped to which body parts, therefore there is no need for a table describing that, with the exception of hints on what should be done about spine.004, hand.L, hand.R, toe.L, toe.R, heel.02.L and heel.02.R.
    1. There is actually nothing you need to do about the heel bones, leave them as they are.
    2. Snap the tails of spine.004, hand.L and hand.R to their heads and move them along the axis they're pointing at, to some whatever point that makes sense to you, e.g. furthest reaching vertex on the hand. No need to be precise here, and thus snapping - just move the tail so that it is roughly where you want it to be.
    3. In order to keep the toe bones aligned and properly positioned, do the following for each toe bone:
      1. Select the foot in object mode,
      2. Snap cursor to the furthest and lowest reaching vertex on the foot,
      3. Copy the X location of that vertex,
      4. Snap the bone to cursor,
      5. Paste the X location to the bone's head,
      6. Snap bone's tail to the head,
      7. Move the head along the Y axis by some amount will make it easy to select but not too big.
  3. In edit mode, set the following rolls for the Metarig bones as described below (if you don't, body parts, mainly shoulders, will get badly rotated after constraining them to the rig after its generation):
    1. shoulder.L, 90 degrees,
    2. shoulder.R, -90 degrees,
    3. All other bones, 0 degrees.
  4. Now we have to set up how our Rigify rig layers will be named and set up. Go to the Object Data Properties tab, open up Rigify Layer Names, and set the table according to the screenshot below, marked as Point 32.
  5. The metarig is now correctly adjusted. Your scene should look as shown in the screenshot below, marked as Point 33.
  6. We highly recommend to save your project here and to continue your work in a new file (i.e. save, then save as a new file and continue your work on the new file), so that you can revert to the version you had until now and adjust the Metarig if needed. You can skip this, work on a single file, adjust the metarig, delete your current rig and generate a new one, but it may or may not be less convenient to rename.
  7. Generate the rig. Congratulations, you have generated the rig and can move to constraining the character to it. Your scene should look as shown in the screenshot below, marked as Point 35.
RigifyLayerNames.png Metarig.png Rig.png
Point 32, Rigify layer names for the rig Point 33, fully adjusted Metarig. Point 35, generated rig.

Constraining the character to the rig and adding the Axis Correction Empties

Now we get to constrain the character to the rig and later edit the rig. Unfortunately, there's even more work in editing the rig than with the metarig.

  1. Hide the metarig, it won't be needed anymore.
  2. On the Pelvis of the T-posed character, add two Copy Rotation object constraints with the settings according to the table below. "x" means there's nothing set.
Setting Copy Rotation Copy Rotation.001
Target rig x
Order ZYX Euler Default
Mix Replace After Original
  1. Copy the constraints to all of the remaining body parts.
  2. At this point, the character is folded into Oni's default pose, described HERE. This is hard to work with, so disable all of the object constraints with the ObjectConstraintEnabler script available HERE. We will also fix the folded pose in a moment.
  3. Add a Copy Location constraint to the Pelvis and:
    1. Set the Target to rig,
    2. Set the Bone to ORG-spine.
  1. Now we need to fix the folded pose. This is done through a set of Empties with specified rotations, which are added to the rotation of each body part through the Copy Rotation.001 constraint (this is also why the Mix of that constraint was set to After Original).
    1. Create a new collection in the Outliner called "Axis Correction Empties".
    2. Add six Arrows Empties, all with their Name showing in the Viewport Display. ( Object Properties / Viewport Display / Name )
    3. Name the empties and place them in the proposed arbitrary postions using cursor snapping, and set their rotations according to the table below - you can place them however you want, as their location does not influence the rig in any way, however, proper placement makes them easy to edit if needed. It's also proposed to place the empties one meter either in front or behind the given body part.
Proposed Axis Correction Empties' placement
Empty Body Part In front of or behind? X rotation Y rotation Z rotation
ACFeet Either foot Behind -90 -52.5 90
ACHandL left_handfist Behind 180 0 90
ACHandR right_handfist Behind 0 0 90
ACLimbs neck Behind -90 0 90
ACPelvis pelvis Front 90 8.6 90
ACSpine mid Front 90 0 90
  1. In your Viewport, open the Viewport Overlay and enable Relationship Lines. These are the lines that will show you lines from constrained objects to their targets. They will give you a better sense of how body parts are copying rotations from the Empties you are about to make. You can also turn Relationship Lines off at any point if they're making the scene hard to read.
  2. Set the Bones of Copy Rotation and Targets of Copy Rotation.001 constraints in character's body parts in accordance with the table below. The table may be intimidating, but it should be logical enough and easy to copy and paste the targets and bones - all of the body parts get targeted to a corresponding ORG bone in the rig through Copy Rotation and get their Axis Correction rotation added through Copy Rotation.001 set to appropriate empty.
Expected result by the end of this header
Body part Copy Rotation / Bone Copy Rotation.001 / Target
pelvis ORG-spine ACPelvis
mid ORG-spine.001 ACSpine
chest ORG-spine.002 ACSpine
neck ORG-spine.003 ACSpine
head ORG-spine.004 ACSpine
right_shoulder ORG-shoulder.R ACLimbs
right_biceps ORG-upper_arm.R ACLimbs
right_wrist ORG-forearm.R ACLimbs
right_handfist ORG-hand.R ACHandR
left_shoulder ORG-shoulder.L ACLimbs
left_biceps ORG-upper_arm.L ACLimbs
left_wrist ORG-forearm.L ACLimbs
left_handfist ORG-hand.L ACHandL
right_thigh ORG-thigh.R ACLimbs
right_calf ORG-shin.R ACLimbs
right_foot ORG-foot.R ACFeet
left_thigh ORG-thigh.L ACLimbs
left_calf ORG-shin.L ACLimbs
left_foot ORG-foot.L ACFeet
  1. Enable the object constraints in the character body parts using the ObjectConstraintEnabler script.
  2. At this point, you should be able to pose the character, as shown in the screenshot on the right.

Removing and editing the rig bones

There are still things to do; if you play around posing your character, you will find out the spine behaviour to be somewhat lackluster, and lacking control over the mid and chest bones. This will now be addressed, and later, bone constraints need to be added to rig controller bones. Let's start off with deleting all the controller bones we don't need.

  1. Select the rig, go to Object Data Properties, Viewport Display and enable In Front. The rig will now always render in front of the character, making it easier to select.
  2. In Edit mode, go to Object Data Properties tab / Skeleton, select Layer 29 (the DEF/Deform) and delete all bones in it.
  3. Select layer 28, and move the root bone to layer 24 (Change Bone Layer, default shortcut is M)
  4. Remove the bones listed below from the rig. Keep in mind it's possible to enable just one layer at a time for your convenience. For the record, we will not be editing MCH or ORG layers until later, so you can ignore their layers for now. IMPORTANT NOTE: Be sure to not delete tweak_spine.001 accidentally, as it's necessary for the rig to function properly.
Bone Layer
tweak_spine Torso
tweak_spine.002 Torso
tweak_spine.003 Torso (Tweak)
spine_fk.001 Torso (Tweak)
spine_fk.002 Torso (Tweak)
upper_arm_tweak.L Arm.L (IK)
forearm_tweak.L Arm.L (IK)
hand_tweak.L Arm.L (IK)
upper_arm_tweak.R Arm.R (IK)
forearm_tweak.R Arm.R (IK)
hand_tweak.R Arm.R (IK)
thigh_tweak.L Leg.L (IK)
shin_tweak.L Leg.L (IK)
foot_tweak.L Leg.L (IK)
thigh_tweak.R Leg.R (IK)
shin_tweak.R Leg.R (IK)
foot_tweak.R Leg.R (IK)
  1. Using 3D Cursor snapping, snap torso and torso_pivot bones to the mid body part.
    1. Since torso and torso_pivot are of the same size, etc. and thus are overlapping each other, feel free to move their tails a bit in the appropriate axis. This applies to all overlapping bones in the rig - if they overlap, move the tail in the axis parallel to the bone.
  2. Reparent shoulder.L and shoulder.R bones from ORG-spine.003 to ORG-spine.002.
  3. Controller bones are now adjusted, and we can move on to ORG and MCH layers. Select the ORG layer (31), reparent the bones and set their Connected box according to the table below. x means no change is needed.
Bone Parent Connected
ORG-spine root x
ORG-spine.001 ORG-spine Yes
ORG-spine.002 ORG-spine.001 Yes
ORG-shoulder.L ORG-spine.002 x
ORG-shoulder.R ORG-spine.002 x
ORG-upper_arm.L x No
ORG-upper_arm.R x No
  1. Select the MCH layer (3) and remove the following bones:
    • MCH-thigh_tweak.L
    • MCH-thigh_tweak.R
    • MCH-shin_tweak.L
    • MCH-shin_tweak.R
    • MCH-foot_tweak.L
    • MCH-foot_tweak.R
  2. Snap MCH-torso.parent and MCH-torso_pivot to the mid body part. (You can also snap them to MCH-spine or MCH-spine.001 bones as they're snapped to mid as well)
  3. With X-Axis mirror enabled, select the MCH-forearm_ik.R bone and extrude it perpendicularly to the axis of the arm. You should now have the MCH-forearm_ik.R.001 and MCH-forearm_ik.L.001 bones. These bones are needed for the wrist snapping function which we'll implement later.

Editing the bone constrants of ORG and MCH bone layers

Now's the time to edit and add bone constraints.

  1. Switch to Pose mode and add a Copy Rotation bone constraint to MCH-forearm_ik.R.001 and MCH-forearm_ik.L.001 bones that you've added in previous points, targeting MCH-forearm_ik.R and MCH-forearm_ik.L bones (i.e. for the MCH-forearm_ik.R.001, Target is rig, while Bone should be set to MCH-forearm_ik.R.001)
  2. Select the ORG layer.
  3. Add bone constraints in accordance to the table below.
Bone Bone Constraint Target Target/Bone
ORG-spine Copy Transforms rig MCH-WGT-hips
ORG-spine.001 Copy Rotation rig tweak_spine.001
ORG-spine.002 Copy Transforms rig MCH-WGT-chest
  1. Delete the Stretch to bone constraint from ORG-spine.003.
  2. Set the Bone in the Copy Transforms bone constraint in ORG-spine.003 to neck.
  3. Select the MCH layer.
  4. Select the MCH-pivot bone.
    1. Set the Influence of the Copy Transforms bone constraint to 1.
    2. Add a Copy Rotation bone constraint, set it to rig / ORG-spine.002 and set its influence to 0.5.
  5. Select the MCH-spine.001 bone, and set the Influence of the Copy Transforms bone constraint to 0.
  6. Select the MCH-spine.002 bone.
    1. Set the Influence of the Copy Transforms bone constraint to 1.
    2. Add a Copy Location bone constraint, and set it to rig / ORG-spine.002.
  7. Select the MCH-STR-neck bone.
    1. Set the Rotation of the Stretch To bone constraint from Swing to XZ.
    2. Add a Damped Track bone constraint.
      1. Move it to the top of the bone constraint list.
      2. Set it to rig / head.
      3. Set the Track Axis to Y if it isn't already.
  8. For both MCH-upper_arm_ik_stretch.L and MCH-upper_arm_ik_stretch.R bones, do the following:
    1. Set the Rotation of the Stretch To bone constraint from Swing to XZ.
    2. Add a Damped Track bone constraint.
      1. Move it to the top of the bone constraint list.
      2. Set it to rig / hand_ik (.L or .R appropriately if it's a right or left hand).
      3. Set the Track Axis to Y if it isn't already.
  9. For both MCH-thigh_ik_stretch.L and MCH-thigh_ik_stretch.R bones, do the following:
    1. Set the Rotation of the Stretch To bone constraint from Swing to XZ.
    2. Add a Damped Track bone constraint.
      1. Move it to the top of the bone constraint list.
      2. Set it to rig / MCH-foot_roll (.L or .R appropriately if it's a right or left leg).
      3. Set the Track Axis to Y if it isn't already.
  10. Disable the Stretch checkbox in both of the IK bone constraints in the following bones:
    • MCH-forearm_ik.L
    • MCH-forearm_ik.R
    • MCH-shin_ik.L
    • MCH-shin_ik.R

Changing custom shapes of rig controller bones

We're getting close to the end. There's still a bit of work to do, but all that remains relates to the rig controller bones in Pose mode. This short header will focus on changing the shapes of the controller bones - these changes are purely visual and have no functional effect on the rig, however, they do make it more more ergonomic and easier to read.

Rig's expected state at point 69
  1. Switch over to all other bone layers except the MCH and ORG layers - all that was related to them is now done.
  2. Select the tweak_spine.001 bone:
    1. Set the Custom Object to WGT-rig_thigh_parent.L - this will make it much more easier to read.
    2. Set the Scale to 1.5.
    3. Disable the Scale to Bone Length checkbox.
  3. Select the spine_fk bone:
    1. Disable the Scale to Bone Length checkbox.
    2. Set the Scale to 0.
  4. For both hand_ik.R and hand_ik.L bones, disable the Scale to Bone Length checkbox.
  5. For both foot_ik.R and foot_ik.L bones, do the following:
    1. Disable the Scale to Bone Length checkbox.
    2. Set the Scale to 2.
  6. For both toe.R and toe.L, set the scale to 0. At this point, the rig should look as shown in the screenshot on the right.

Editing the script

Now we'll need to edit the Rig Layers panel a bit and add the wrist snapping functionality by putting three code snippets into and running it.

  1. Go to the Scripting tab and select the script.
  2. Right at the start of the script you will see the rig_id field. Copy its value and save it in some text editor, as you'll be pasting it in the next few steps.
  3. Find the following line (use another text editor if you can't find it in Blender's Text Editor):
        props.bones = '["upper_arm_ik.L", "upper_arm_ik_target.L", "hand_ik.L"]'

Add the following code snippet below it - this will add a button and functionality for the wrist snapping on the left arm - using the MCH-forearm_ik.L.001 bone that was created in points 52 and 53. Also, replace YOURRIGID with your rig_id from point 71.

            group2 = group1.row(align=True)
            props = group2.operator('pose.rigify_generic_snap_YOURRIGID', text='IK wrist (hand.L)', icon='SNAP_ON')
            props.output_bones = '["hand_ik.L"]'
            props.input_bones = '["MCH-forearm_ik.L.001"]'
            props.ctrl_bones = '["MCH-forearm_ik.L.001"]'
            props.tooltip = 'IK hand to wrist'
  1. Find the following line:
        props.bones = '["upper_arm_ik.R", "hand_ik.R", "upper_arm_ik_target.R"]' 

Add the following code snippet below it - this will add a button and functionality for the wrist snapping on the right arm. Also, replace YOURRIGID with your rig_id from point 71.

            group2 = group1.row(align=True)
            props = group2.operator('pose.rigify_generic_snap_YOURRIGID', text='IK wrist (hand.R)', icon='SNAP_ON')
            props.output_bones = '["hand_ik.R"]'
            props.input_bones = '["MCH-forearm_ik.R.001"]'
            props.ctrl_bones = '["MCH-forearm_ik.R.001"]'
            props.tooltip = 'IK hand to wrist'
            if is_selected({'upper_arm_ik.R', 'hand_ik.R', 'upper_arm_parent.R', 'upper_arm_ik_target.R'}):

  1. Find the following line:
        row.prop(, 'layers', index=8, toggle=True, text='Torso') 

Change it to the following:

        row.prop(, 'layers', index=9, toggle=True, text='Pose Matching')

        row = col.row()
  1. Find the following line:
        row.prop(, 'layers', index=9, toggle=True, text='Torso (Tweak)')

Change it to the following:

        row.prop(, 'layers', index=8, toggle=True, text='Torso')
Rig's expected state at point 80.
Rig's expected state at point 80, with hand_ik.R selected, showing the newly added IK wrist snapping functionality.
  1. Find the following code:
        row.prop(, 'layers', index=21, toggle=True, text='Leg.R (FK)')

        row = col.row()

Remove the row = col.row() and row.seperator() lines.

  1. Find the following line:
        row.prop(, 'layers', index=28, toggle=True, text='Root')

Change the value of index to 24. Index is the layer number, and Root should be layer 24, not 28.

  1. We recommend backing up your file at this point.
  2. Run the script, and move to the Layout tab. Your rig should look as shown in the screenshots on the right.

Adding the Rigify Axis Correction Empties

Before we add the Pose Matching functionality, we need to create Axis Correction Empties that will account for Rigify's axis orientation.

  1. Switch to Object Mode.
  2. Duplicate the Axis Correction Empties collection and rename it to Rigify Axis Correction Empties
    1. Rename the ACPelvis.001 to RACHead and move it in the global Z axis so that it is aligned with the head along the Y axis (or 3D cursor snap it)
    2. Rename the remaining empties in the newly-made collection by removing the .001 suffix and changing the AC prefix to RAC.
    3. Set the rotations of the empties according to the table below:
Empty X rotation Y rotation Z rotation
RACFeet 38.1 90 0
RACHandL -180 0 90
RACHandR 0 0 -90
RACHead -90 -90 0
RACLimbs 90 90 0
RACSpine 180 -90 0

Adding bone constraints to rig controller bones and drivers

This is the final section of this tutorial. Now we just have to add the Pose Matching functionality, so we can constrain the rig to imported animations in Pose 1 and Pose 2 collections. We do that by adding two new bones to the rig, bone constraints to the rig controller bones and then drivers which will control the influence of the bone constraints through the Z location of the newly added bones. We will also

  1. Select the rig, go to Edit mode and select the Pose Matching layer.
  2. Add a new bone named Pose1.
  3. Set its transforms as listed below (or make it as big as you want, this is purely a visual/ergonomic matter):
    • Head X,Y,Z: 1,0,0
    • Tail X,Y,Z: 1,0,1
  4. Duplicate the bone and rename it to Pose2.
  5. Set its transforms as listed below (it will be simply mirrored along the X axis)
    • Head X,Y,Z: -1,0,0
    • Tail X,Y,Z: -1,0,1
  6. Switch to Pose mode.
  7. For both Pose1 and Pose2 bones, select them, go to Bone Properties tab, Viewport Display, Custom Shape and set the Custom Object to WGT-rig_shoulder.L.
    1. You can also set the Scale to 10 and disable the Scale to Bone Length checkbox for them if you want.
  8. For now, move both Pose 1 and Pose 2 in Global Z axis so that they are below the "floor" (XY plane).
  9. Select the Torso layer and all of the FK layers in the Rig Layers panel.
  10. Select the hips bone.
    1. Add three Copy Rotation bone constraints, and move the one without the suffix to the bottom of the list (so the order of the bone constraints going from the top to bottom is Copy Rotation.001, Copy Rotation.002, Copy Rotation). Copy Rotation.001 and Copy Rotation.002 will be used for pose matching, Copy Rotation will be used for axis correction.
    2. In the Copy Rotation constraint, set the Mix to After Original.
  11. Now we'll have to add the drivers controlling the influence of each Copy Rotation constraint. As shown in Pierrick Picaut's tutorial, you can do that by right clicking on the Influence value and pressing Add Driver (same applies to any other property in any other constraint). Once you add a driver, you can edit it either through Edit Driver or through the Driver Editor - both are selectable within the same menu.
    1. Add a driver to the Influence of each Copy Rotation constraint in accordance with the table below:
Copy Rotation.001 Copy Rotation.002 Copy Rotation
  • Driver Type: Scripted Expression (default setting)
  • Expression: var
  • Amount of input variables: one (default setting)
  • Input Variable type: Transform Channel (default setting)
  • Input Variable name: var (default setting)
  • Object: rig
  • Bone: Pose1
  • Type: Z Location
  • Space: World Space (default setting)

Same settings as in Copy Rotation.001, with the exception of:

  • Bone: Pose2
  • Driver Type: Scripted Expression (default setting)
  • Expression: max(var1,var2) (press Enter to get rid of the invalid expression error, if you have it)
  • Amount of input variables: two (press Add Input Variable)

First input variable:

  • Input Variable type: Transform Channel (default setting)
  • Input Variable name: var1
  • Object: rig
  • Bone: Pose1
  • Type: Z Location
  • Space: World Space (default setting)

Second input variable:

  • Input Variable type: Transform Channel (be sure to change it to this, added variables have Single Property set as default)
  • Input Variable name: var2
  • Object: rig
  • Bone: Pose2
  • Type: Z Location
  • Space: World Space (default setting)
  1. You can check if the drivers are working by moving Pose1 and Pose2 bones along global Z axis and checking if the Influence of Copy Rotation bone constraints in hips or Input Variable values in their drivers change.
  2. Copy the bone constraints from the hips bone to the following bones:
    • tweak_spine.001
    • chest
    • shoulder.R
    • shoulder.L
    • neck
    • head
    • upper_arm_fk.R
    • upper_arm_fk.L
    • forearm_fk.R
    • forearm_fk.L
    • hand_fk.R
    • hand_fk.L
    • thigh_fk.R
    • thigh_fk.L
    • shin_fk.R
    • shin_fk.L
    • foot_fk.L
    • foot_fk.R
  3. Unfortunately, because Blender at this moment does not copy drivers when copying bone constraints, the bone constraints you've just copied are lacking the drivers. Because of this, you have to copy the drivers manually - simply right click on the Influence value of Copy Rotation constraint, press Copy Driver, and go through all bones in the upper list and Paste Driver onto the Influence of the Copy Rotation in each bone. Do this for all three Copy Rotation bone constraints.
  4. Add two Copy Location constraints to torso and torso_pivot bones, and make sure they're named Copy Location.001 and Copy Location.002.
  5. Copy Influence Drivers from any of the bones in point 96 and paste them into the Influence of Copy Location constraints in torso and torso_pivot, in accordance with the numbers of bone constraints (e.g. copy the driver from hips' Copy Rotation.001 Influence and paste it into Influence of Copy Location.001 in torso and torso_pivot).
  6. Set the Copy Rotation constraints' Axis correction Target in accordance with the table below.
Bone Copy Rotation target
hips RACSpine
tweak_spine.001 RACHead
chest RACSpine
neck RACHead
head RACHead
shoulder.R RACLimbs
shoulder.L RACLimbs
upper_arm_fk.R RACLimbs
upper_arm_fk.L RACLimbs
forearm_fk.R RACLimbs
forearm_fk.L RACLimbs
hand_fk.R RACHandL
hand_fk.L RACHandR
thigh_fk.R RACLimbs
thigh_fk.L RACLimbs
shin_fk.R RACLimbs
shin_fk.L RACLimbs
foot_fk.R RACFeet
foot_fk.L RACFeet
Finished rig showing the pose matching functionality
  1. Select any FK (green) bone and set the IK-FK slider to 1. Do this for all four limbs. This has to be done because pose matching works only through FK.
  2. Using the RigBoneConstraintTargetSetter script, set the targets for the Copy Rotation.001 and Copy Rotation.002 bone constraints. You can do that by having the rig in Pose mode, going to the Scripting tab, copying and pasting the script, and running it with prefix value set to 1, and then set to 2.
  3. If you didn't get any errors, move one of the Pose bones in the global Z axis above the XY plane - the T-posed character should now snap to one of the animations in the Pose collections, as shown in the screenshot on the right.
  4. Congratulations! The rig is now ready to be used.