The visual representation of characters in 3D games is done with the use of models, textures and animations.
In the past, characters needed to have the exact same skeleton to share animations. This limited character diversity as their height and proportions had to be the same as well. The older FIFA games, for example, had players all be the same size because creating a separate skeleton — and a set of animations — would have been a nightmare.
Luckily for game developers nowadays, most engines come with a system to allow reusing animations as long as the skeletal hierarchy is compatible. This allows you to use the same animations for characters of all shapes and sizes. In Unity, this system is called Mecanim. It allows for easy set up of animations, the blending between them and retargeting of humanoid animations between models.
Being able to reuse animations allows you to use animations from the asset store and websites like mixamo.com for your own custom characters. This saves a ton of time!
In this tutorial, you’ll learn how to prepare a humanoid model using Blender and how to bring it into Unity. More specifically, you’ll learn how to:
- Create an armature (skeleton) for a character and rig it
- Modify the character with accessories and objects
- Export to FBX
- Import Blender models
- Create and tweak a humanoid avatar
- Attach objects to a character
- Animate a humanoid in Unity
Time to jump right in!
Before you begin, verify you meet the following requirements:
- The latest stable release of Unity is installed.
- The latest stable 64-bit version of Blender is installed.
- You have a minimal understanding of the Unity editor. Check out some of the beginner tutorials on the website.
- Some experience with Blender is recommended. Here are some tutorials to get started.
Download the source materials by clicking the link at the top or bottom of this tutorial and unzip it somewhere.
Open the starter project folder and navigate to the Assets\RW\Models folder. Open CuteCharacter.blend in Blender.
The file contains the following data:
- A low poly humanoid character model.
- CuteCharacter material.
- A reference to the CuteBase texture contained in the same folder as the model.
After opening the file, you should see the character model on the left:
Note that it’s mirrored on the X-axis, this will make the whole process a lot easier along the way.
The right side has the simple texture image loaded:
The first step to animating this character is rigging it.
Rigging the Character
Rigging is creating an armature, the skeleton of the model. An armature has several connected bones to which you can connect vertices, so they move along whenever a bone gets moved around.
Hover over the 3D View to bring it into focus. Then, add a new armature by holding Shift and pressing A to open the Add Menu. Select Armature > Single Bone.
The armature and its very first bone, also known as the “root bone” have now been created. With the armature still selected, find the X-Ray check box in the Display section of the Properties tab and check it.
The armature is now visible through the character. This makes the creation of the skeleton easier.
Before diving in and creating the full structure, it’s important to understand how it needs to be set up to be compatible with Unity’s Humanoid Avatar.
Due to the way Unity maps the bones to its own system, some key bones are necessary.
Unity expects a minimum of 15 bones, which are:
- Hips (root bone)
- Lower spine
- Upper spine
- Two upper arms
- Two lower arms
- Two hands
- Two upper legs
- Two lower legs
The rig you’ll be creating includes all of the above bones and some extra ones for added stability when animating.
Make sure the armature is still selected and press Tab to enter Edit mode. Select the root bone by right-clicking it.
Open the Bone tab on the right in the Properties panel so you can quickly make changes, and rename the root bone to Hips by entering it in the name field and pressing Enter.
Time to create the bone structure!
Select the bottom sphere of the Hips bone and press G, Z, 0.5 and Enter in sequence to move it up around where you’d expect a belly button to be.
Now, select the top sphere and press G, Z, 0.1 and Enter to move it up a bit.
To get multiple spine bones, you’ll need to subdivide the Hips bone in three pieces. Select the Hips bone, press W to open the Specials menu and select Subdivide. By default, this splits the bone into two pieces, so change the Number of Cuts in the bottom of the Tool panel on the left to 2.
With the spine split, the new bones are named Hips.001 and Hips.002. That’s not a good way of naming bones; rename the bones by selecting each one and changing the name in the right Bone panel.
Name the top one Chest and the middle one LowerSpine.
Next up are the leg bones. Duplicate the Hips bone by selecting it, then press Shift + D and right-click at the end to confirm.
If you look at the Bone panel on the right, you’ll see a bone named Hips.001 selected. Rename this to UpperLeg.L. The L stands for left. This makes it clear what side the bone is on and will help with mirroring later on.
Rotate the UpperLeg.L bone on the Y axis by pressing R, Y, 180 and Enter in succession.
Now move it in place horizontally by pressing G, X, .23 and Enter in that order. After that, press G, Z, -.2 and Enter to get it in position vertically.
Select the bottom sphere (also called a connector) and move it down by pressing G, Z, -.3 and Enter in that order.
The leg needs to be split up to be bendable. Select the UpperLeg.L bone, press W and select Subdivide to split the leg in two (ouch!). This results in two leg bones; name the bottom one LowerLeg.L.
The last part of the legs are the feet. Switch to a side view by pressing 3 on your numpad and press period (.) on your numpad to focus on the lower leg.
Zoom out a bit until you can see a good part of the lower leg.
Now select the bottom connector and extend it to make a foot bone by pressing E, Y, -.18 and Enter.
Rename the newly created bone to Foot.L using the Bone panel.
Now might be a good time to save the file. Press CTRL + S and left click on the file name that pops up. Feel free to do this periodically, Blender is quite stable, but it can crash now and then.
Switch back to the front view by pressing 1 on your numpad. Before moving on to the head, you’ll need to parent the leg to the hips. Luckily this is pretty simple!
Select UpperLeg.L and find the Parent drop-down inside of the Relations section of the Bone panel. Click it and select Hips.
On to the head! Select the connector at the top of the Chest bone, press E, Z, .055 and Enter consecutively. This is the neck bone so name it Neck in the Bone panel.
To add the head bone, keep the top connector selected and press E, Z, .95 and Enter in that order.
Name the newly created bone Head.
Next is the left shoulder connector. Select the top connector of the Chest bone and press E, X, .08 and Enter to add the new bone. Move it down a bit by selecting the rightmost connector and pressing G, Z, -.09 and Enter.
Name this bone ShoulderConnector.L. This bone will connect the chest to the shoulder. Just for the record, none of this is anatomically correct in any way, and it doesn’t need to be. :]
Select the rightmost connector again and press E, X, .85 and Enter in that order. This creates one large bone that needs to be split up to create the remaining bones for the left side.
Select the newly made bone, press W and choose Subdivide. Change the number of cuts in the bottom left to 3, so you get four pieces in total.
Name these bones as follows, from left to right:
The way these bones are currently laid out might look good at first glance, but because the way the connector between the arm pieces sits (also known as an elbow), the arm won’t be able to bend correctly. Press Z to enter the wireframe view and take a look for yourself:
The red line indicates where the elbow is now and the white line indicates the arm’s bending point on the mesh. In order to fix this, select LowerArm.L and move it to the right by typing G, X, .09 and Enter.
That’s it as far as adding bones goes. How about the right side though?
Well, I don’t know about you, but I’ll take any shortcut I can get to get the work done! That’s why the next step is mirroring the bones on the left to the right with a few keystrokes.
Since Blender 2.79, there’s a nifty new feature added to quickly mirror the bones of an armature in just a few simple steps! Before adding this, you had to duplicate, mirror manually, adjust the names and fix the role of the bones. If you ever had to do that, you know the pain it can cause!
To start, deselect all of the bones by pressing A until there are no more orange selection outlines.
Next, select only the bones on the left side (the character’s left side that is, it’s your right) by holding Shift and right-clicking the bones one-by-one. Don’t forget about the foot!
With those bones selected, press W and select Symmetrize.
This is all you need to do to get a perfect mirrored version of the selected bones:
The bones will also all have .R at the end of their name instead of .L to show their position.
Save the file and prepare to move on to rigging.
Weight painting is the process of binding bones to a 3D mesh. Each bone gets attached to a group of vertices with a certain amount of weight.
The weight decides how “hard” the vertices will be pulled and pushed by the bone.
Doing this manually would take a while since you’d have to paint the weight of every single bone. Luckily, Blender can take care of most of the grunt work by automatically weight painting based on how close the bones are to the vertices.
Press Tab to switch to Object mode. Select the model first, then hold Shift and right-click the armature to select that as well.
Now press CTRL + P to open the Parent menu and choose With Automatic Weights to parent the model to the armature and perform automatic weight painting.
You might not notice a difference visually, but the bones are now connected to the mesh.
Before testing this out, verify the Pivot Point is set to Median Point mode by checking the bottom panel:
Change it to Median Point if it’s still set to Cursor mode.
On to the cool part! Change to Pose mode, select a bone and rotate it around by pressing R and then moving your mouse around. Do this with each bone on the center and the model’s left side to check if everything was weighted correctly.
Be sure to rotate the view around and test out the rotation from other angles as well by holding down the scroll wheel and moving your mouse around.
After checking all of the bones, you may have noticed the eyes don’t move with the head, which looks a bit weird, to say the least:
To attach the eyes to the head, you’ll need to do some actual weight painting. Keep the armature in Pose mode, then hold Shift and right-click the model to add it to the selection. Now enter Weight Paint mode, and you’re ready to do some painting.
In this mode, you can select bones by holding CTRL and right-clicking on the bone. Select the Head bone and rotate it backward by pressing R, X, -90 and Enter in that order.
To attach the eyes to the Head bone, select the Add brush in the Brush section of the tool panel on the left.
Press Z to enter wireframe mode and rotate the view until at least one of the eyes isn’t in front of the head anymore. Now, paint along the vertices of the eyes to increase the weight until the eyes aren’t floating anymore.
The weight can be seen visually by the color on the mesh; the values range from 0 (dark blue) to 1 (vibrant red). To check out the result, reset the view by pressing numpad 1 and press Alt (or Option) + R to reset the rotation of the Head bone.
The eyes are now correctly connected to the head.
With the basic weight painting done, it’s time to add some details.
Accessories in this context are objects that are attached to the character but aren’t a part of its body. This section discusses two ways of attaching objects: to the model itself and as a separate, reusable object that connects to a bone.
The former is a simple hat, and the latter is a weapon for the character to hold.
Before continuing, press Z to jump out of wireframe mode and press A, then Alt (or Option) + R to reset the rotation of all bones.
Editing the Character
The first way of adding more details to your character is easier to work with, but it comes with some limitations. As you’ll be working on the model itself — which is mirrored — all geometry added will be copied from the left side to the right and vice-versa. This makes it impossible to add anything unique to one side. Because the geometry is a part of a particular model, it also can’t be reused for other characters. It’s perfect for any situation where those limitations aren’t a problem.
If you’ve followed along with the tutorial until now, you’ll probably still be in Weight Paint mode. This is perfect as you’ll need to do some more weight painting after adding the hat. Press Tab to enter Edit mode and start off by switching the selection mode to Vertex by pressing CTRL + Tab and selecting Vertex in the menu.
Now select any vertex on top of the head by right-clicking, as long as it’s above the red line (which is an UV seam used for texturing). Press CTRL + L to select all connected vertices, this selects the whole model. Now select the UV delimiter by selecting UVs in the bottom left panel.
Only the top of the head will be selected now.
Select the edge loop underneath as well by holding Shift and Alt (or Option) and then right-clicking on any of the first horizontal edges below.
Now duplicate the selected faces by pressing Shift + D and then pressing Enter. Move the duplicated faces up a bit by pressing G, Z and 0.01 in that order.
Next, scale the whole selection up by pressing S, 1.05 and Enter.
This moves the hat away from the head a bit, so you don’t end up with some of the faces Z-fighting.
The hat is still like a piece of flesh floating around, do the following to attach it to the model:
- Select just the bottom row of the “hat” by pressing A to deselect everything and then holding Alt (or Option) and right-clicking on one of the bottom edges.
- Make it straight by press S, Z and 0 in that order.
- Press E to extrude and press Enter to confirm.
- Press S to start scaling and move your cursor towards the model until the edges are inside of the head. Rotate the view around to make this easier to see. Press Enter to confirm the scaling.
This gave the hat some depth so it can look all right from all sides without any holes. A hat made from human skin probably isn’t what you had in mind though. To change the color, you’ll have to unwrap its UVs first so it can fit nicely on the texture.
Select the entire hat by selecting any vertex on the hat and then pressing CTRL + L. Change the delimiter to Normal this time to select all of the connected vertices.
For this hat, you’ll perform one of the easiest unwraps in existence: from the view. Press numpad 1 to get a front view, then press U to open the Unwrap menu and select Project From View.
If you look at the right side of the Blender window where the texture is visible, you’ll notice some vertices were added that look similar to half of the hat:
You can select all of these by moving your cursor over to the texture and pressing A. Actions in Blender are context sensitive depending on where your cursor is placed, so make sure to keep it somewhere inside the region of the texture for now.
Now press G to move the UVs over to the blue splotch, confirm the movement by pressing Enter and then scale the selection down until it fits inside the blue region by pressing S and confirming with Enter.
If you now look at the character again, you’ll notice his hat turned blue.
You can edit the texture image to make it any color you want.
Now, position the cursor back on the left, somewhere near the model, and press Tab to return to Weight Paint mode. Rotate the Head bone around a bit to check if the hat is connected.
It looks like you’re in luck! Because the vertices of the hat are all so near to the Head bone, they’re included automatically. If this weren’t the case, you’d have to paint the hat as you did with the eyes.
Next up is creating and attaching a separate object.
For this part, you’ll be creating a simple staff that will act as a weapon for the character to hold. It’s easy to imagine a sword, an axe or even a magic wand instead, but creating a complex weapon is outside the scope of this tutorial.
Get into Object mode and press Shift + A to open the Add menu. Select Mesh > Cylinder to add a new cylinder to the scene.
The default cylinder is too big, so adjust the cylinder parameters in the bottom left: change Radius to 0.04 and set the Depth to 1.2.
This makes the cylinder thinner and shorter.
Make the cylinder smooth by pressing the Smooth button in the Shading section in the Tool Shelf on the left.
Right now, the cylinder doesn’t have any material assigned yet. To assign material, open the Material tab in the Properties panel on the right and select CuteMaterial from the drop-down next to the New button.
To turn the cylinder into a brown staff, you’ll need to unwrap its UVs first. Press Tab to enter Edit mode, press U to open the Unwrap menu and select Project From View.
Move your cursor over the texture on the right, press G to start moving the UVs and move it over the brown patch on the texture. Confirm the movement with Enter and scale it down by pressing S and moving your mouse, so the UVs fit inside.
The staff is now brown colored. Don’t worry about the awkward positioning; you’ll be dealing with that next.
Open the Constraints tab in the Properties panel. Add a new constraint by clicking the Add Object Constraint drop-down and selecting Child Of.
Constraints are used to limit the position, rotation and/or scale of an object. In this case, it’ll be used to parent the cylinder to the hand bone of the character. This way — if you create any animations — the object will be attached to the hand at all times. This makes previewing the animation a lot easier and allows you to prevent the object from intersecting with the body.
Setting up the constraint is straightforward. Click the Target drop-down and select Armature. Now click the Vertex Group drop-down and select Hand.R.
After doing this, you’ll notice the staff immediately snaps to the character’s right hand. The position and rotation aren’t quite right, though. Rotate the staff on the Z-axis by 90 degrees by pressing R, X, 90 and Enter in that order. Now move it forward a bit by pressing G, Y, -0.4 and Enter. Much better!
Time to put the staff to the test. Get back into Object mode by pressing Tab, select the armature and switch to Pose mode using the drop-down at the bottom. Rotate the view so you can see the staff clearly, select UpperArm.R and rotate it around a bit by pressing R and moving your mouse around. The staff will keep following the hand around as if the character held it.
The character and its accessories are now done. Save the file and pat yourself on the back for a job well done.
Next up is exporting the model and the armature to Unity.
Exporting to Other Formats
Unity can handle Blender’s .blend just fine as long as Blender is installed on the system. However, when sharing models with different people, it’s often better to use a format like .FBX or .OBJ that doesn’t require any other software. That’s also the reason why most of our tutorials come with .FBX model files instead of the source .blend ones.
Exporting to FBX with Blender is easy. To start, select File > Export > FBX (.fbx) in the top menu.
You’ll now see the export view. Unlike most applications, Blender doesn’t open an extra window but replaces the whole contents of the window instead.
You can choose a location to save the file by choosing a folder on the left or by typing in the location directly at the top. The export settings are at the bottom left of the window:
These default export settings will work with Unity, but there’s a chance they might make a mess in more complex scenes as it will export everything, even lamps and cameras. To make a clean export, make the following changes:
Deselect Camera, Lamp and Other. You can do this by holding down Shift and clicking the options you want to disable.
With just these options selected, you won’t get any undesired objects exported. Now check the !EXPERIMENTAL! Apply Transform checkbox right below the options you deselected. This applies the position, rotation and scale of all objects. That means any non-uniform values will be reset; if the rotation was set to (X:23, Y:125, Z:7), for example, it will be set to (X:0, Y:0, Z:0).
Switch to the Geometries tab by clicking the Geometries button, and uncheck the Use Modifiers Render Setting checkbox. This allows you to keep a high poly count for renders inside Blender, but keep it low for use inside of Unity.
Next, open the Armatures tab, check Only Deform Bones and uncheck Add Leaf Bones. This prevents Blender from adding extra bones to the armature. Leaf bones are only needed for compatibility with Maya. Non-deform bones like control bones are only needed in the modeling software to make precise adjustments; they’re useless in a game engine like Unity.
The default Animation options are fine, so you don’t need to tinker with those.
Now that you have all of this set up, it would be tedious if you needed to do this every single time you want to export a file. That’s where the presets come in. You can save all of these settings in Blender’s internal options for later use.
To do this, click the + button next to the Operator Presets drop-down, type a name for the preset in the textbox and click the OK button. For the sake of this tutorial feel free to name it Unity FBX.
If you now open the Operator Presets drop-down, you can select the newly made preset:
Doing so will instantly apply the settings. This works across all files, so from now on you can easily export any Blender file to FBX for use in Unity.
The final step is the actual exporting. This tutorial uses the .blend file in Unity for animating, so feel free to save the FBX file anywhere you want by selecting a folder on the left and pressing the Export FBX button at the top right.
Save the file and close Blender. It’s finally time to jump into Unity and use the model.
Setting Up a Humanoid
Open the starter project in Unity and look at the Project view.
Here’s a quick overview of what these are for:
- Animation Controllers: Used to put the character’s animation controller into.
- Animations: Contains a simple idle animation.
- Models: Here’s where you edited and saved the character. It also includes the dojo model and some textures.
- Music: A simple Chinese song to get into the dojo mood.
- Scenes: The Dojo scene.
If it’s not already open, open the Dojo scene from the Scenes folder. This is an inside overview of a dojo with an Audio Source to play the music in the background.
With the overview out of the way, on to using the character!
To start, select the CuteCharacter model in the Models folder and open the Rig tab in the Inspector. Open the Animation Type drop-down and select Humanoid.
This flags this character as a humanoid one, so Unity can use it as such. Now click Apply to save these settings.
After a short re-import, you’ll notice the Configure… button is now available. Click this button to start linking the bones to Unity’s Mecanim system.
Look at the Scene view and rotate the view around until the character faces you. Notice the green bones; these are the ones Unity uses internally. Clicking any of these will select the corresponding bone in both the Hierarchy and in the Inspector.
The way Unity uses these bones is by acting like a puppeteer. Instead of straight up using animation files to update the bones every frame, it reads the values and applies those to every humanoid based on their Avatar definition. This allows for flexibility when it comes to body shapes. Take the character you’ve been working on, for instance; its proportions are not realistic, but that doesn’t matter as its skeleton is also adjusted to fit while still having the essential bones like a spine, arms, legs, etc. Some of the bones may be shorter than in most humans, but they’re there.
Now focus on the Inspector, you’ll see a human shape with green and gray circles spread around. All solid circles are necessary for the Avatar system to work. If any of these are missing, they’ll turn red, and you won’t be able to animate the character correctly.
The dotted ones are optional bones for more complex rigs. Any body parts that are grayed out are missing, but not essential. This character doesn’t have any fingers for example.
Below that is the full overview of the bones, and this is where you need to link body parts to bones. If any of the circles are red, you’ll need to (re)assign a bone. The skeleton you’ve made is entirely up to spec when it comes to Unity, so no adjustments are necessary. Hurray!
Click the Apply button on the bottom-right and click the Muscles & Settings button at the top of the Inspector. This allows you to view and tweak the virtual muscles.
You’ll now see three sections:
- Muscle Group Preview
- Per-Muscle Settings
- Additional Settings
The first one has several sliders you can move from left to right to test if the muscles are mapped correctly. Try them out and see what they do. Note that the finger ones won’t have any effect since the character doesn’t have any fingers. Press the Reset All button after every test to reset all preview sliders.
The Per-Muscle Settings section contains sub-sections that can be unfolded by clicking the arrow next to them. Every one of these has some more specific previews and allows you to specify the minimum and maximum angles to prevent overlapping for your specific model.
Expand the Left Arm section and try sliding around the Arm Down-Up slider. Notice what happens with the minimum value selected:
The arm is moving through the character’s body. Ouch!
To fix this, set the preview slider to its lowest value and change the minimum angle of Arm Down-Up to -20.
Do the same for Right Arm > Arm Down-Up.
That concludes the tweaking of the muscles. There are more muscles you can tweak to prevent overlapping, but for the sake of this tutorial leave it at the arms up and down movement.
Press the Apply button at the bottom-right to save the changes to the Avatar and press Done to close the mapping mode.
Now it’s time to add the character to the scene and give it an animation to play.
Using the Character
To add the character, drag the CuteCharacter model from the Models folder into the Hierarchy.
Set the rotation of CuteCharacter to (X:0, Y:180, Z:0), so it’s facing towards the camera.
Create a new animation controller by right-clicking the RW\Animation Controllers folder and selecting Create > Animation Controller.
Name it CharacterController and double-click it to open the Animator window. Now drag the Idle animation from the RW\Animations folder onto the Animator grid to make it the default animation.
Next, select CuteCharacter in the Hierarchy and click the selector button next to the Controller field. Select CharacterController in the selection window.
As a final step, expand the CuteCharacter in the Hierarchy and drag Cylinder to Hand_R to parent it. This is the limitation of adding a separate object as I discussed earlier. Not doing this will result in the weapon just floating around the character.
That’s it! Press the play button to see the character in motion.
Now press the play button again to stop the scene and press CTRL + S to save the changes you’ve made.
Where to Go From Here?
Congratulations on finishing this tutorial. You can download the final project using the link at the top or bottom of this tutorial.
In this tutorial, you learned how to:
- Create an armature (skeleton) for a character and rig it
- Modify the character with accessories and objects
- Export to FBX
- Import Blender models
- Create and tweak a humanoid avatar
- Attach objects to a character
- Animate a humanoid in Unity
To use the knowledge you’ve gained, you can create some accessories yourself and give them a different color or pattern. If you know some modeling, you can also create a character from scratch and rig it.
To learn more about Blender, check out these tutorials:
To learn more about Mecanim and the Avatar system, read this blog post by Unity.
Thanks so much for reading this tutorial to the end. If you have any questions or comments, feel free to join the discussion below.