I made a sample .BLEND file showing the Rigify to Unity Mechanim process.

For some reason, information on this everyday process was hard for me to find on the web. Sometimes old postings just get buried in all the other information out there. And even though I found a couple good references, I could NOT find a sample Blender .BLEND file which actually contained a rig which was ready for Unity’s Mechanim Humanoid.

There’s actually a good reason for this-- the Blender Rigify process creates a new rig from scratch every time you want to make a new character. Unlike Unity Mechanim’s “retarget” process, you cannot just grab a completed Rigify rig and stretch it into position onto each new character mesh. All of the FK and IK target bones and vertex groups would just be a mess. So nobody ends up sharing a .BLEND file because it has a special-purpose rig that’s only good for one character.

That said, it can still be useful to view a .BLEND file with something in it. So that’s what I am sharing here. I didn’t create Rigify, I didn’t create the script which converts Rigify rigs to Mechanim-ready FBX exports, I just followed the latest process I could find to rig up a generic human-proportions mid-poly skeleton mesh. And more importantly, I included all the up-to-date instructions inside the .BLEND file ready for you to try your own mesh.

https://www.dropbox.com/s/iuc9b8wspz8nmhh/rigify-to-mechanim-skeleton.blend?dl=0

3 Likes

There are notes inside the .BLEND but I will share them here as well.

This is a working .blend file in Blender 2.79.

User “tryny” at GitHub posted a script “Rigify4Mechanim.py” which extends the Blender Rigify add-on.
https://github.com/trynyty/Rigify_DeformBones

User “danko” at YouTube posted a video demonstrating the process.

User “halley” put together a generic skeleton mesh and walked through the process to offer a blend file.
https://www.dropbox.com/s/iuc9b8wspz8nmhh/rigify-to-mechanim-skeleton.blend?dl=0

Setup:

  • Enable User Preferences > File > Auto Run Python Scripts.
  • Click User Preferences > Add-Ons > Install Add-On from File: Rigify4Mechanim.py.
  • Enable User Preferences > Add-Ons > “Rigify” and “Rigify for Unity”.
  • If using Blender 2.79 or higher, enable User Preferences > Add-Ons > Rigify > Rigify Legacy Mode.
    (The newer version has a ton of facial bones which Mecanim cannot use, and other bone changes.)

Mesh:

  • Make or load mesh(es) belonging to the character.
  • If you have any vertex groups for these meshes, consider removing them (Mechanim can’t use them).
  • Approximate T-pose with some relaxed knees and elbows is best.

Construction of temporary Meta-Rig:

  • Scale the mesh if desired. Any scale is okay but it seems easiest with 1 blender unit = 1 meter.
  • Add > Armature > Human (Meta-Rig).
    This produces a new armature called “metarig” which is just a template which we can discard later.
  • On metarig, set Properties > Display > X-Ray and Max Draw Type to Wire to see rig through mesh.
  • Scale “metarig” to match the character mesh, and Apply Scale. The scale must be 1.0.
  • Edit metarig, moving all joints into place. Using Tools > Options tab > X-Axis Mirror helps a lot.

Construction of Blender Rigify Rig:

  • Select the metarig.
  • On metarig, click Properties > Armature > Rigify Buttons, Generate.
    This produces a new armature called “rig” that shadows the metarig, with many layers of bones.
    You can delete or hide the “metarig” at this point.
  • Armatures have their own layers. The “rig” has bones which are named “WGT-", "DEF-” and “ORG-*”.
  • The DEF- bones are intended to be for mesh deformation in Blender Rigify,
    but are not suitable for matching the Unity Mechanim humanoid skeleton assumptions.
  • On rig, click Properties > Armature > Rigify to Unity converter > Convert to Unity rig.
    This will remove deformation flags on DEF- bones, and add deformation on most ORG- bones instead.
  • On rig, click Properties > Skeleton > Layers > last layer only. This shows ORG- bones.
    The ORG- bones are just clones of the bones in the temporary metarig, which Rigify doesn’t use.
    However, we will now focus on ORG- bones for deformations instead of the Rigify DEF- bones.

Attaching and Binding Mesh to the Unity Rig:

  • Adjust envelopes on each ORG- bone as desired (optional). This can save time weight-painting.
  • Select all the mesh(es) and also the “rig” Armature last (it should appear brighter).
  • Ctrl+P to parent the mesh(es) to the rig. Choose Armature > Envelope Weights or Automatic Weights.
  • Each mesh will now have a number of vertex groups starting with ORG- matching all ORG- bones.
  • Use weight painting mode on the meshes to fine-tune the weighting to each ORG- bone.
    [Tutorials elsewhere.]
  • Hit T in the 3D View to show the Tools sidebar on the left.
  • For each mesh, select it and hit Tab to enter Edit mode, then click Clean in the Weight Tools section.
    This will remove vertex group entries for any vertices at 0.0 weight, for space and performance.

Using FK vs IK:

  • Select the rig in the 3D View and go to Pose mode.
  • Hit N in the 3D View to show the Numbers sidebar on the right.
  • Under the Rig Layers section, turn on all layers.
  • Select all bones (easier than all FK bones and IK targets).
    This will fill out the Rig Main Properties section in the Numbers sidebar.
  • Adjust the FK/IK properties to 0.0 for full FK or 1.0 for full IK control.
  • Set Length IK to 1.0 to ensure deformations use the natural bone lengths.
  • Set Auto-Stretch IK to 0.0 if you do not want limbs to stretch to IK targets.

Creating Animations:

  • Select the rig in the 3D View and go to Pose mode.
  • Hit N in the 3D View to show the Numbers sidebar.
  • Under the Rig Layers section, turn on all desired layers.
  • Keyframe animations using all the handy Rigify IK targets or FK bones as desired.
  • Define each animation in the Dopesheet as separate Actions.
    [Tutorials elsewhere.]

Exporting to Unity:

  • Select the rig and all meshes to export.
  • On rig, choose or type a filename into Properties > Armature > Rigify to Unity converter > Export file.
  • Click Rigify to Unity converter > Export to FBX file.
    All of the appropriate compatible ORG- bones, meshes, and action animations will be saved.
4 Likes

THAAAAAAAANKKKKKKS!!!

I was able to make it work thanks to you!!!

Thank you for posting such guide. Isn´t solved it by native blender rig (basic armature) now?
I like this solution for a full IK-humanoid Unity rig. Thanks. I´ll try this one.

Thank you SO much!!

Such a shame the plugin just doesn’t work on Blender 2.8, I love how I can use the program there more…

In fact I tried to append a character (model and rig) I made in 2.8 (because opening the file on 2.79 will open an empty scene) and trying to pose on the older version would result a very wonky animation - some of the bones would take more than one frame to move, both on Blender and once exported. At least the appended metarig wasn’t affected, so it’s safe if you generate the rig on 2.79.

EDIT: Just found an addon that works on 2.8. I have to say it’s for the Basic Human rig from the non-Legacy Mode in this case.

1 Like

Can you share addon that works on 2.8

It’s in the message you quoted and in your own reply. Just click the link.

Thank you!

It seems like it’s not working for 2.8.1 though