Now that we know how to create a skeleton and perform skinning thanks to the first part of this article, we are ready to export the model to Unity and animate it with Mecanim.
Play the live demo at the end of the article to see the results !
In order to use your model in Unity, you can either go with the Maya file (*.mb or *.ma) or export to FBX (*.fbx). It is good practice to stick with the format of your 3D package as long as you are working on your model (if you need to test in Unity at different stages) and then export to FBX so Unity can work with a file that is smaller and easier to import.
If you go for FBX export, make sure you check the following options in the export window :
- Animation > Animation
- Animation > Deformed Models > Skins
- Animation > Constraints > Constraints
- Animation > Constraints > Skeleton Definitions
Mecanim integration in Unity
Once you have your file, copy it under the Assets folder of your Unity project so it can be automatically imported. Then, select the file in Unity’s project browser so that you can see its properties in the inspector. Go to the “Rig” tab and select the following options :
- Animation Type : Humanoid
- Avatar Definition : Create From This Model
Now you can move your model to the scene and attach an Animation Controller to bring your character to life. I could go through the following steps about creating the animation controller and configuring animations and blend trees but you’ll be better off with Will Goldstone’s awesome video tutorial available on Unity3D’s official YouTube channel.
The steps described in this article are the exact ones I followed in order to animate the Professor Layton character I modeled a few days ago. So here it is in action :
Naturally, you can also play this mini-game directly in your browser :
I hope you found this article useful for integrating your models into Mecanim, and if you have questions or remarks, feel free to leave a comment !