Importing and Exporting Models (Maya)
Accepted File Types
- Unity accepts the FBX file format. This is the recommended method and this is what this tutorial will cover.
- Unity will also accept Maya files directly (.ma or .mb). What happens is that when you import an .ma or .mb file into Unity, Unity will automatically open up Maya in the background and do an automated FBX Export. If there's any animation, you will have to bake it either inside Maya or inside Unity.
Things to Know
- Note that Unity currently does not support Blendshapes/Deformers/Modifiers.
- Unity can still see hidden meshes. Make sure to clean up the scene in the 3D modeling package before export.
FBX Export (for Maya)
- Clean up your model. Delete any hidden meshes, make extra sure your model is made of only squares and triangles, etc, etc. Refer to the 3D Modeler Overview for best practices.
- Go to File -> Export All (see Fig. 1). File:Exportall.jpg
- Select FBX Export as the file type (see Fig. 2). File:Filetype.jpg
- In the export options, check Smooth Mesh, check Animation, check Bake Animation, check Deformed Models/Skins, uncheck constraints, uncheck lights, uncheck cameras.
- In the FBX File Format section of the options, select type ASCII. (see Fig. 3). File:Fbx2010.jpg
- Name your file. For the sake of the programmer, be sure to use a pre-agreed upon naming scheme for all your models.
- Click Export All.
- You may receive warnings about complex animations, constraints, etc. Ignore these (see Fig. 4). File:Warnings.jpg
- If you want to split your animations up as multiple FBX exports (covered below), just make sure to set the timeline to the specified animation. In the FBX Export options, under bake animation, set the start and end frames. Use the model_name@animation_name naming scheme, for example, dragon@flapping (see Fig. 5 and 6). File:Timeline.jpg File:Naming.jpg
- Double check the export in Unity!
Importing into Unity
- Drag the files into the Project panel inside Unity directly from the folder they are stored. Unity will automatically import the files into the Unity Project Folder. You should also create a dedicated folder for the models if you're the programmer (see Fig. 7). File:Import.jpg
- The @ naming scheme will allow Unity to automatically detect and assign animations to models. To check your animations, drag the primary model file into the hierarchy panel (see Fig. 8). File:Dragintoscene.jpg
- To open the animation panel, go to the upper right corner of any panel and click on the button there. Go to Add Tab -> Animation (see Fig. 9). File:Animationtab.jpg
- You can use standard Maya controls to navigate the viewport space (Alt + Mouseclick to move, f to focus).
- Select the model in the Hierarchy Panel. Go to the Animation Panel's animation drop-down menu (to the upper left of the graph area) and select the animation you want to view (see Fig. 10). File:Viewanimations.jpg
- Make sure to mouse scroll down in the graph area to zoom out in order to tell Unity to give the animation enough space to play.
- Hit Play to check your animation.
- Repeat for all the animations desired.
- If your animation doesn't seem to be playing, you may not have baked the animation during FBX Export. If you select the animation inside the Project Panel, there's a checkbox for Bake Animation in the Inspector Panel inside of Unity. However, it may be best to re-do the FBX Export itself.
- Also make sure that the scale factor for your model and your animations are the same inside the Inspector Panel.
- If your animation is playing strangely (twitching, bones start flying to key frames that don't exist, etc), this may be due to a bug between FBX 2011 and Unity. A workaround is to export your file using FBX 2010. UPDATE: This bug should be fixed in Unity version 3.20f4.
Importing Animations into Unity
There are two methods for importing animations into Unity:
Method 1: Split into multiple files with one as the model file and the animation files labeled with the @ naming scheme (e.g. dragon.fbx, email@example.com, firstname.lastname@example.org). Unity will automatically interpret them.
Method 2: One giant FBX file containing all of the animations which will be split up inside Unity. Animations can be split up in the Inspector Panel.
Go here to learn more: http://unity3d.com/support/documentation/Manual/Animations.html