Using groups to rotate FBX files

An efficient solution to dealing with the discrepancy between Maya and Unity is to act on Maya's side and rotate the model on its y axis there. Though, as we write, this problem is going to be solved soon by Maya LT, we offer a solution here that prevents the imported FBX file from acting strangely once they are turned into prefabs in Unity. The idea is to use the so-called "groups" to apply the transformations required and yet get a clean hierarchy for the prefab to appear in Unity. Let's see how to do it.

Getting ready

Open the scene again with the model we used before and be ready to follow our instructions.

How to do it...

In this recipe, we will show you how to use groups and hierarchies in Maya to export a model that will not show its back once it gets imported into Unity. Have the Maya scene open on your screen.

  1. From the outliner panel, select the root node of your model. Be sure that the model is at the 0,0,0 position with 0,0,0 rotation.
    How to do it...
  2. With root node selected, press Ctrl+G to create a group in the hierarchy.
  3. Double-click on the newly created group name to edit it and type rot_180 (this is actually just for reference so we know what the group means).
  4. Set a value, namely 180, for the rotation on the y axis in the Transform Attributes panel.
  5. With the rot_180 group selected in the hierarchy, press Ctrl+G again to create another group. Name this group export after double-clicking on the group name in the hierarchy.
  6. Now you can select the export node to export the selection in order to get an FBX file out of this model.

How it works...

By using one group for flipping the model on the y axis and another to make a selection featuring neither rotations nor translations for the export, we made sure that the FBX file won't have any unexpected rotation or position offsets that will affect its behavior once it gets scripted into the code in Unity.

There's more...

Another technique we will only mention here is to use your programming skills and code an AssetPostprocessor class to handle the process automatically.

AssetPostprocessor is a class in Unity, provided with several methods to act on the pipeline for importing assets into Unity.

What one could do is add a custom attribute to the model in Maya, something like turn me 180 degrees on the y axis when imported, and let the AssetPostprocessor class read this attribute and perform the transformation.

You can learn more about the AssetPostprocessor class by checking the scripting reference guide at http://docs.unity3d.com/ScriptReference/AssetPostprocessor.html.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.235.176