Create a rig character

Create a simple humanoid rig character in Blender for use in Unity

These videos are intended to show the process of creating a rig for animation in Blender and export it to Unity. There are many great videos online on how to animate and rig, for those who'd like to deep dive into those subjects. The intention in this serie is to show very simple examples so anyone who'd like to try to create their own characters and animations should be able to do this.

Unfold each headline for detailed text

Importing updates for Blender 4.1 regarding inserting Keyframes changes. Hitting I in the viewport no longer brings up the keying set meny. You can instead use hotkey "K" for Insert Keyframe Menu. 

Part 1: Creating a mesh unfold >

In this tutorial we'll create a very simple prototype character that can be elaborated on and further developed in different variations. You can use the mesh with a rig to create animations in Blender and export those to Unity, or use existing animations in Unity with this mesh. You can also use the rigged animations together with other mesh characters with the same Unity bone structure.

(If you already have a mesh character, you can skip part 1 and go right ahead to part 2)

To follow along this tutorial it helps a lot to enable the Blender Add-ons - Add Mesh: Extra Objects and - Add-ons - Mesh: LoopTools. You'll find these under Edit - Preferences, click on Add-ons and search for  "Add Mesh: Extra Objects" and "Mesh: LoopTools", check the boxes for each of these add-ons. To later rig it, you will also need the add-on Rigging: Rigify.


Part 2: Creating a metarig unfold >

Preparations

The mesh object should now be finished. (See part 1.)

Open the project with your mesh character (or append the mesh object into a new project). It's a good idea to save the project with the mesh character under a new name so you easily can go back and reuse the mesh to develop it in some other way. To do so, open project and choose save as with a new name. 


Note: Also, later on, keep a copy of the project file with your finished metarig so you can go back and create a rigify version of it later if you need. More on rigify in part 3.

 

Using the mesh character from Part 1. Our character is already in a T-pose which is good, this pose is often used as a start pose for rigged characters. Name your mesh object to something meaningful for you. Make sure you have enabled the Add-on  Rigging: Rigify. (Otherwise you can reach this from Edit - Preferences.) 


About bone definitions:

It's worth noticing the usual definitions of the bones in the rig, the thick base is called the root or head,  the thin top side is called the tip or tail. The part between rot and tip is called the body of the bone.


Creating a metarig


In Object mode, go to menu Add - Armature - Human (Meta-Rig)


With metarig object selected, tab to Edit mode. Turn on X-Ray to see the contours of your mesh. You can also use Wireframe mode to see better.

Set pivot to 3D Cursor. The cursor should be at zero position. 

In Edit mode, scale the rig to fit the character's size. We'll need to adjust the proportions, so let's start with selecting all of the rig with A. Scale down so the pelvis is in the right place. Deselect the bones from the pelvis and downwards.

Scale up again until the lower part of the bone (the root) above pelvis (spine.001) is around the part of the spine that bends inwards, the lumbar spine area.

You can also adjust the edge loops later on the character to match this area for best results.


Deselect spine.001 and continue scaling, let spine.002 be around the upper area of the spine that bends, (around the level of the armpits or lower part of the Sternum).

Deselect the bones up until spine.004, scale up so spine.005 starts at the beginning of the head part.


To scale sideways, set Pivot to Median point. Select the arms up to the shoulder joint. Press S and X, to scale on x axis. Adjust the bones by scaling (S) or moving (G) until they fit inside the mesh in the right places. Be careful not to separate any of the spine bones, move the tail and head together as some bones need to be perfectly aligned.


For some adjustments, such as rotation, it can be easier to select one part, for example a part of the arm, then check the X-Axis Mirror in the Tool tab on the Sidebar.

Don't forget to turn it off when you don't need it.


Go to Object mode and select the mesh object ("in this example it is still named Cube"), then select Edit mode and make minor adjustments if needed. (Avoid making any changes to the mesh after you have added it to the armature rig.)

In this example, I'm going to raise the loops at the armpits a bit upwards. 


Remove bones that you don't need for your mesh. 


A note about face bones: If you are keeping face bones, you may need to upgrade the Face Rig. Look at Object Data Properties for the metarig (when selected the little green figure down to the left). Under Rigify it may be a note that says "This metarig uses the old face rig", click on Upgrade Face Rig. You need to do this before you Generate a Rig.


Some bones won't be needed for this example, but you could save a version of the project or object before you remove the bones. Then you could always go back and continue editing on the mesh if you need to use the facial and hand bones for another character.


To remove facial bones, expand the structure of the metarig in the Outliner. For a quick unfold of all the bones, hold shift and click on the expand arrow. 

In 3D Viewport window and x-ray mode, make a rough circle select of the whole face, check the outliner and unselect any spine bone that might have been selected. (Shift and rightclick to unfold the whole metarig hierarchy.) You can unselect in Outliner by holding Cntrl and click twice. For this case we can delete all bones from face and down. Press Delete, select Bones.

For this character, we only need upper arm, forearm and hands. So, we can make a rough selection of the hands area and remove everything below the bones hand.L and hand.R. We can also remove breast bones, and the top bone, spine.006.


Select the tip (tail) of the spine.005 and move it on z axis so it covers the whole head.


Check from top view and side view if the bones needs further alignment and you can make some adjustments on the mesh where you like.


Here I'm inserting one more loop on each arm between the elbow and shoulder joint with a factor around 0.7. From top view (num pad 7), the mesh elbows and elbow bone joints could be moved slightly back on the y-axis.


Now we can save the project and continue with preparing the rig and mesh for Unity, and if we like, create a simple animation before we export the character and animation to Unity.


Prepare rig for Unity


To prepare the rig and mesh for Unity's scale and coordinate system we can change the scale and rotation of the rig and mesh. It is not totally necessary but can make things easier in Unity.


Select the metarig in Object mode. Press S for Scale, type 100, confirm with mouse click. Menu Object - Apply Scale. Press S again, now type 0.01, confirm. (The metarig should now have the scale 0.010.

On the X Rotation, type -90. Menu Object - Apply Rotation. Rotate back to 90.


Do the same with the mesh object, set scale to 100, apply, scale back 0.01. Set rotation on x -90, apply and rotate back 90.


After this you can parent the mesh to the Armature rig and set the weights (the latter is how much a bone should affect a vertex group).


In Outliner Window, with mesh object selected. 

Cntrl click on metarig (mesh obj should be orange, metarig yellow (the yellow one is going to be the parent), this color marking is visible both in Ouliner window and in viewport. 

Menu Object - Parent - Armature Deform - With Automatic Weights


If you should take a look at the mesh now in Weight mode, you should see that it has got a vertex group for each bone and colored areas for each of those groups.


(Now may be a good time to name the mesh to something suitable if you haven't already.)


You could export the rigged character now as an FBX file without creating any animation but in this example we are going to create a simple animation first. 


Create an animation, action clip  


With metarig selected, choose workspace Animation. This should take you to Pose Mode.

In Blender, the animation clips are called an Action. You create the animations by setting keyframes for bones in specific postions over time (viewed in the timeline). You can create several actions. In this example I'm going to create a very simple Wave action/animation. 


A little about FK, IK and keyframes. In the example I'm often inserting keyframes for the whole character (instead of just specific bones) this often helps when working with IK. You can think of FK as a way of moving arm- and legjoints on a LEGO figure, while in IK you're moving the arms and legs on a puppet that has strings connected to the feet and hands.


In Object mode with metarig selected, go to Anmation workspace, this should take you to Pose Mode. Press Wireframe icon as viewport shading.

Here you can select all or individual bones, as selected they turn blue.

The window below is Dope Sheet with default editing context Dope Sheet, I recommend here to choose Action Editor as editing context.


Press Auto Keying button (the rec button on the play bar).


Animate your character as you want it or follow the video example.


Importing updates for Blender 4.1 regarding inserting Keyframes changes. Hitting I in the viewport no longer brings up the keying set meny. You can instead use hotkey "K" for Insert Keyframe Menu. 

"I" key adds the keyframes for the active Keying Set. (Found under "Keying" in Timeline menu. See video "Blender 4.1 New Features Official Overview" at 3.47, https://youtu.be/PmIbMx_RM6k?si=KZG8leaqzIMbNSK7. Keying Set can be set in Preferences, Animation - Timeline. You can also use Shift K to set an Active Keying Set.



Exporting the rig to Unity


Select both metarig and mesh object, go to menu File - Export - FBX.

On the right side of export window, next to Limit to, check "Selected Objects", click on Armature, shift click Mesh. (Meaning you choose to include only the selected Armature and mesh in your fbx file.)

Scroll down, under Armature, deselect "Add Leaf Bones".

Name your file to something meaningful then press Export FBX


Importing the rig and animation to Unity


In Unity, under Assets, create a folder or go to one you already have, where you want to place your fbx model. Right click and choose "Import New Asset". Locate your saved fbx model and press Import.


In Unity's Inspector you should now be looking at the Import Settings. Under the Rig tab, select Humanoid under Animation Type, click on Apply. You should now be able to check the Configure settings by pressing button "Configure". If all went well, all bones should now be mapped and marked green. Click Done at the bottom. (You can also leave the preview by clicking on the leftmost arrow next to "Avatar Configuration".

Drag your fbx model into the scene and try out some animation. 

There should be an Animator component attached to your object. An Avatar should've been created at the import. You also need to create an Animator Controller or use an already existing one.



Part 3: Rigify animation to Unity unfold >

With Rigify you can create more complex animations and have access to more tools. When you're done, in this video example, the animation is baked and exported and then used by a human metarig, prepared for Unity's bonesystem.

In this example we are going to bake and copy the animation from a Rigify rig to a prepared metarig character, prepared for Unity's bonesystem. We don't need to export the Rigify rig to Unity, that is complicated and unnecessary since Unity doesn't make use of the Rigify bones. Instead, you can do as many animations you need in Rigify and use them in Unity this way on a regular human character. The video assumes you have enabled the Add-on  Rigging: Rigify.  The video also assumes you already have a rigged metarig with a mesh character.

Open a copy of the project with your prepared metarig, rigged and adjusted to your mesh character. See part 1 and part 2 in this tutorial serie.

Or you could also start a new project and append the metarig and mesh objects from the previous project.


To be able to copy the animation to the metarig, the bones needs to be recognized, let's rename them like the rigify bones.

Select metarig, in Edit mode, select all bones. Go to Menu Edit - Batch Rename, in the settings choose: Selected, All, Bones, Type: Set Name, Prefix, in the field Name, type DEF-, don't forget the hyphen, press OK


Note: Before you generate the rigify rig and create a long animation, be aware that some bones will not match completely when putting the animation back on the metarig.  In the video you can see there is an example of the arms, after IK animating the arms, there's an offset in the rotation in the upper arm/shoulder joint. You could fix this afterwards by rotating the upper arm and set new keyframes where needed. OR, you could set the bone to Manual X in the Rigify type settings, then the rig will keep the same roll/rotation in the upper arm as the original metarig. To find this setting, select the (in this case) the upper_arm.L bone in Pose Mode, go to Bone Properties, scroll down under Rigify Type, in the Rotation Axis field, choose Manual X instead of Automatic.

To get a better understanding of the rolls and rotaion of bones, you can turn on Axes, you'll find that under Armature icon, Object Data Properties, Viewport Display, check the box Axes. When a bone is selected you will be able to se the individual axes, (if you turn on the Wireframe or X-ray, you can see that the Y axis runs along inside the bone from bottom to top). 



See Arm rotation problem explained in images.


Generate the rig. 

Now you can create an animation with all the tools that the Rigify has available.



To be continued...