Creating Reusable Characters With Blender and Unity

Characters in video games are often as memorable as the accompanying gameplay and music. In this tutorial, you’ll learn how to prepare a humanoid model using Blender and how to bring it into Unity. By Eric Van de Kerckhove.

5 (3) · 2 Reviews

Download materials
Save for later
Share
You are currently viewing page 4 of 5 of this article. Click here to view the first page.

Exporting to Other Formats

Note: If you’re not interested in exporting models to other formats so you can share them with other people, feel free to skip this section. Just save the file and close Blender.

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 .blend files.

Exporting to FBX with Blender is easy. To start, select File > Export > FBX (.fbx) in the top menu.

You’ll now see a Blender File View window. 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 right side 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:

In the Include section, deselect Camera, Lamp and Other. You can do this by holding down Shift and clicking the options you want to disable.

With these options selected, you won’t get any undesired objects exported. Now check the Apply Transform checkbox at the bottom of the Transform section. 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).

Next, open the Armatures section, 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 at the top, 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 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 Assets folder in the Project view.
Here’s a quick overview of what these are for:

  • Animations: Contains a simple idle animation.
  • Materials: The materials of the character and the dojo.
  • Models: Here’s where you edited and saved the character. It also includes the dojo model and some textures.
  • Music: An Asian inspired 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.

With the overview out of the way, on to using the character!

Avatar Mapping

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 enabled. 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!

Switch to the Muscles & Settings tab 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 you can leave them at their default settings.

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.