Blender & Unity: Manually Rigging Blender Humanoid Characters for use with Unity Mecanim

I’m definitely no character animator by trade, but there comes a time when you end up with a Unity project that somehow requires it. There are obviously many automatic rigging methods available (Blender does actually have an auto-Rigging system called Rigify for biped humanoids) and you could even try to download other rigs made by other people and plonk them into your scene, but I found that so many of the rigs including the rigify one seems to involve so many complicated bones you don’t need, so you end up having to sift through the bones, deleting so many unwanted bones, renaming bones, perhaps even having the impression of the impossibility of rigging up them bones.

Although it may seem terrifying at the beginning (I’m not an animator or rigging specialist!), I found that surprisingly, it is not that difficult to manually rig up all your bones if what you have is a very simple humanoid character. You just need to be orderly and to stick with the admittedly tedious bone naming process. (Although our character is blobby, we’re sticking with a humanoid as we’re going to use it with the Kinect to sync it with the movement of the human user, and our human user is going to return a humanoid set of values that we’ll need to rig up our character to…)

According to the Unity Blog’s post on Mecanim Humanoid:

“The skeleton rig must respect a standard hierarchy to be compatible with our Humanoid Rig. The skeleton may have any number of in-between bones between humanoid bones, but it must respect the following pattern:”
Hips – Upper Leg – Lower Leg – Foot – Toes
Hips – Spine – Chest – Neck – Head
Chest – Shoulder – Arm – Forearm – Hand
Hand – Proximal – Intermediate – Distal

This is the list of all the bones you need (I found it useful to copy and paste in these names directly)


Optional: eye.L and eye.R

For starters: Ensure that your character model is positioned at origin and that its pivot point is also at origin (0,0,0). Make sure you reset the scale to 1 just in case (Ctrl+A, Select Scale). The hip bone is the key bone in all this, so start by creating one big bone starting from the bottom of hip to top of the chest. Hit Space and start typing “Subdivide Multi” (Armature) and give it 2 cuts so you get 3 bones. These will form the hips, abdomen and chest bone.

After you’ve done the main spine bones, you can turn on x-axis mirror.

– Select the ball on top of the bottom bone (hips bone). Make sure Options>Armature option>X-Axis Mirror is selected, then press Shift-E to extrude mirrored bones. When you’re in mirror mode, every time you create a new bone, you’ll have a second one mirrored on the other side of the X-Axis. Remember that you’ll have to rename BOTH bones later on – if you are facing your model face-on, also remember that L is actually to the right and R is to the left, and name it accordingly.

– Arrange the leg bone into position (you may need uncheck “Connected” in order to let the leg bone go into the right position). Reposition the leg bones away from the hip. Subdivide Multi (1 cut) this leg bone into two bones, forming upperLeg and lowerLeg.

– Shift-E to extrude two more foot and toe bones, and also add in the collarbone, arms and neck+head bone. Do make sure you keep it all in a standing T-pose (as if the character is standing in the shape of the letter t).

– Ensure that all of your bones are renamed correctly as per the list. If there is an L bone there must always be a R bone.

– Go into Object Mode and Select first the character and then Shift select the armature. Press Ctrl+P and select Set Parent To – Armature Deform – With automatic weights. Your computer might lag for a second before its all connected up.

From there, you’re in the home stretch. Export your Blender model in FBX format and then import it into Unity, and in Unity set the rig to humanoid (instead of generic) and at the bottom of that, hit Apply.

Let the wild rigging begin!

See also:
Animate Anything with Mecanim

as3isolib, regular expressions

Today’s roundup of experiments and snippets:


I downloaded as3isolib some time ago but never had time to play around with it. Today I went back to their site after a long while and realised that all their example swfs on their documentation site were broken. Most of the examples were originally for Flex but I sometimes like to work in Flash IDE itself so this is an example how to use it with as3iso. Credit goes to the documentation wiki as well as various commenters correcting each other on the wiki.

As3isolib is an open-source ActionScript 3.0 Isometric Library developed to assist in creating isometrically projected content (such as games and graphics) targeted for the Flash player platform.”

This is a simple example of an IsoScene with an IsoBox. It uses classFactory to create the shadow below itself, and TweenMax to handle the animation.

import as3isolib.core.ClassFactory;
import as3isolib.core.IFactory;
import as3isolib.core.IIsoDisplayObject;
import as3isolib.display.IsoView;
import as3isolib.display.primitive.IsoBox;
import as3isolib.display.renderers.DefaultShadowRenderer;
import as3isolib.display.scene.IsoGrid;
import as3isolib.display.scene.IsoScene;
import as3isolib.geom.IsoMath;
import as3isolib.geom.Pt;

import com.greensock.TweenMax;

var box:IIsoDisplayObject;
var scene:IsoScene;
var tm:TweenMax;

scene = new IsoScene();

var g:IsoGrid = new IsoGrid();
g.showOrigin = false;
g.addEventListener(MouseEvent.CLICK, grid_mouseHandler);

box = new IsoBox();
box.setSize(25, 25, 25);
box.moveBy(0, 0, 20);


var factory:as3isolib.core.ClassFactory = new as3isolib.core.ClassFactory(DefaultShadowRenderer); = {shadowColor:0x000000,shadowAlpha:0.15,drawAll:false};
scene.styleRenderers = [factory];

var view:IsoView = new IsoView();
view.clipContent = true;
view.setSize(stage.stageWidth, stage.stageHeight);


function grid_mouseHandler(evt:ProxyEvent):void
var mEvt:MouseEvent = MouseEvent(evt.targetEvent);
var pt:Pt = new Pt(mEvt.localX,mEvt.localY);
var squareSize:int = 50;//
var gridX:int = Math.floor(pt.x / squareSize);
var gridY:int = Math.floor(pt.y / squareSize);, 0.5, {x:gridX * squareSize, y:gridY * squareSize, onComplete:completeCallback});

if (! hasEventListener(Event.ENTER_FRAME))
this.addEventListener(Event.ENTER_FRAME, enterFrameHandler);

function completeCallback():void
this.removeEventListener(Event.ENTER_FRAME, enterFrameHandler);

function enterFrameHandler(evt:Event):void

Using regular expressions to parse loaderInfo url name:

I have a folder full of swfs which have an external file / xml entry where they must get their information from. Each swf file is named in the format xxx_0.swf where xxx is a 3 letter suffix and 0 is any number (can be any number of digits). The issue is that when you try to return the url name you will actually get the full directory path. Don’t know if this is the most efficient way, but the solution I eventually went with involves putting each URL segment (divided by a slash) into an seperate array item and then going to the last one. Finally we slice off the front 4 characters (xxx_) and last 4 characters off (.swf):

var myFileNameArray:Array = new Array();
var num:Number;
var myFileNumber:String;
var myFileNum:Number;

var myFileName:String = this.loaderInfo.url.split(“/”).pop().replace(/%5F/g, “_”).replace(/%2D/gi,”-“);
myFileName = this.loaderInfo.url.split(“/”).pop().replace(/%5F/g, “_”).replace(/%2D/gi,”-“);
myFileNameArray = myFileName.split(“/”);
num = myFileNameArray.length;
myFileNumber = myFileNameArray[num-1].slice(4,-4);
myFileNum = Number(myFileNumber);