Importing and Exporting Models (Maya)

From Unity3D

Jump to: navigation, search

Additional Resources:


Contents

Accepted File Types

  1. Unity accepts the FBX file format. This is the recommended method and this is what this tutorial will cover.
  2. 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

  1. Note that Unity currently does not support Blendshapes/Deformers/Modifiers.
  2. Unity can still see hidden meshes. Make sure to clean up the scene in the 3D modeling package before export.


FBX Export (for Maya)

  1. 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.
  2. Go to File -> Export All (see Fig. 1).
    Fig. 1, Export All (click for larger version)
  3. Select FBX Export as the file type (see Fig. 2).
    Fig. 2, FBX Emport (click for larger version
  4. In the export options, check Smooth Mesh, check Animation, check Bake Animation, check Deformed Models/Skins, uncheck constraints, uncheck lights, uncheck cameras.
  5. In the FBX File Format section of the options, select type ASCII. (see Fig. 3).
    Fig. 3, FBX File Format (click for larger version
  6. Name your file. For the sake of the programmer, be sure to use a pre-agreed upon naming scheme for all your models.
  7. Click Export All.
  8. You may receive warnings about complex animations, constraints, etc. Ignore these (see Fig. 4).
    Fig. 4, Warnings (click for larger version
  9. 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).
    Fig. 5, Timeline (click for larger version)
    Fig. 6, Naming (click for larger version)
  10. Double check the export in Unity!


Importing into Unity

  1. 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).
    Fig. 7, Importing (click for larger version)
  2. 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).
    Fig. 8, Dragging into Scene (click for larger version
  3. 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).
    Fig. 9, Animation Panel (click for larger version)
  4. You can use standard Maya controls to navigate the viewport space (Alt + Mouseclick to move, f to focus).
  5. 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).
    Fig. 10, Animation Viewing
  6. 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.
  7. Hit Play to check your animation.
  8. Repeat for all the animations desired.


Animation Troubleshooting

  1. 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.
  2. Also make sure that the scale factor for your model and your animations are the same inside the Inspector Panel.
  3. 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, dragon@flapping.fbx, dragon@landing.fbx). 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

Personal tools