Using our animations with Unity's Mecanim
i. Importing and using our animations as Generic
ii. Importing and using our animations as Humanoid
Games without animations aren't as fun. Fortunately, Mecanim, Unity’s animation system, provides ample possibilities for animating your characters. In this tutorial, you will learn how to apply our animations to your characters.
Note: This tutorial is meant for those familiar with Unity. If you aren't, I recommend you familiarize yourself with the Unity interface using their .
There are two ways in how you’ll go about using our animations. This depends on your project's workflow.
There are times you might apply animations to your character outside of Unity and only after import to connect them through the Animator Controller without using the Mocanim Avatar.
Or you might have multiple characters in your game that utilize the same animation asset. In this case you’ll have to get into the details of Unity’s Mecanim Avatar setup in order to use the animations across multiple characters.
We’ll go over both ways on how to do that with our animations.
Importing and using our animations as Generic
1. Lets create a new unity project and call it AAAnimators
An empty project is created.
2. In the Project window we need to create a new folder with a new name, lets use AAAnimators.
3. Afterwards, right click it and Import New Asset. In the file finder locate the T-Pose of your model & animation files.
4. Wait for Unity to import your animation assets. Great! Now after importing you should have all the assets in the AAAnimators folder. These might differ, depending on the assets you are importing. Here I imported the T-pose & roll forward mobility animations. We'll be going over how to apply the roll forward animation to our T-pose model.
5. Add your T pose model into the scene by dragging it into either the Scene or Hierarchy window.
6. Position it so the Camera can see the model in its viewport.
7. Now in order to animate your models you will need to create a new Animator Controller. Right click in the Project window and select Create / Animator Controller; or use the file menu Assets / Create / Animation Controller. Let’s call the new controller "AAAnimators Controller".
8. Click your model in the scene or the Hierarchy window. Hold Alt, click & drag the AAAnimators controller in the Controller property.
9. Open the Animator window.
The Animator should be empty with only Any State & Entry items present.
10. Drag the animation take directly into the Animator. It should appear attached to the Entry.
11. Now your T-Pose model should play the animation after you hit the Play button.
At this point proceed with Unity’s Mocanim tutorials to setup the Mocanim properly.
Importing and using our animations as Humanoid
The following section explains how to use a different technique in order to link one or multiple characters with our animation assets. Follow the above (1-5) instructions to import your animation model and our animation assets.
Note: All of our animation packages have the following steps complete and have the Avatar Definition set to copy from the T-Pose Avatar for that particular animation pack, so you won't have to do this after purchasing our mocap packs, but you might have to follow these instructions after modifying our animations outside of unity or perhaps you'd like to understand more about Unity's proprietary animation system.
1. Click on the animation model you’d like to configure so you can see it’s Import Settings in the Inspector. I'll be using our T-pose model. Here click on the “Rig” tab, which is where you assign or create an avatar definition. What we want is to create an Avatar Definition for that model so we can link it to our animation assets. Avatar definition is a special feature for working with humanoid characters. The 'Avatar' system is based on humanoid layout, and helps Unity identify which parts of the model correspond to the legs, arms, head and body.
2. There are three Animation Type options, lets pick Humanoid and click on Configure button.
There is a big difference in how Humanoid animation is handled vs Generic. Humanoid relies on MuscleClip information to manipulate the rig, whereas a Generic rig utilizes transform information for manipulation. The two are incompatible by design.
3. In the Avatar Definition pick “Create From This Model” for your model. To put it simple, this option "links" your animation rig with Unity's Mecanim engine. From this point forward, any model with animation rig of identical bone structure can be controlled by Unity.
You only have to set up your model's Avatar Definition once. You will want to re-use that setup for any animation you import into your project, so for any additional animation you'll pick “Copy from Other Avatar”. After picking this option you’ll have to chose the Avatar Definition source and pick your already made Avatar Definition.
4. Click the Configure button. Unapplied import settings dialogue might appear. Click Apply
You should see the animation Avatar Mapping appear in the Inspector.
5. Our models use the default MotionBuilder rig setup, which should map to Unity’s rig setup quite nicely for the most part, but we’ll have to change the Spine, Chest & Upper Chest bone mappings because the MotionBuilder rig has more bones than what Unity’s Avatar Definition expects. This is the process of mapping a rig to Unity's animation Avatar system.
In the Avatar Mapping window:
- Map the Unity Spine bone to robot:Spine bone.
- Map the Unity’s Chest bone to robot:Spine1.
- Map the Upper Chest bone to robot:Spine2.
For our models the Avatar setup should now look like this:
But your models might have a slightly different configuration so you’ll have to make sure they match properly.
6. Afterwards click Done to exit the Avatar Mapping window.
Now, in order to link your model with our animations place your model into the scene. Here I've placed the T-pose.
7. Position it so the Camera can see the model in its viewport.
8. Now in order to animate your models you will need to create a new Animator Controller. Animator controllers are unity generated assets that contain one or more state machines to determine which animations are being played. Its easy to setup a script that controls whether your character is running, jumping or shooting. Right click in the Project window and select Create / Animator Controller; or use the file menu Assets / Create / Animation Controller. Let’s call the new controller "AAAnimators Controller".
9. Click your model in the scene or the Hierarchy window. Hold Alt, click & drag the AAAnimators controller in the Controller property.
10. Open the Animator window.
The Animator should be empty with only Any State & Entry items present.
11. Now open the animation asset you'd like to use with this Animation Controller. The animation data is inside.
12. Drag it into the Animator window. It should appear attached to the Entry.
13. At this point follow Unity’s instructions on how to configure and use it’s Mocanim controller.
Here are some good video tutorials on how to work with Unity's Mecanim. Have fun!
- • Unity's Animation tutorials
- • Mecanim Animation Tutorial in Unity - How to Animate in Unity with Mecanim
- • Unity 2017 - Biped Animation using Mecanim [C#][Tutorial]
- • Character animation setup tutorial - Live Training
Also, here is a PDF version of this document