- Home /
Exporting props from Maya: Best Practice?
Briefly: When I export an asset from Maya into Unity, a non-trivial amount of busywork needs to be done to the imported fbx to make it usable in Unity. In particular, Maya knows nothing about Unity physics, so I have to dig into the internals of the fbx in Unity to setup the components properly to handle Unity physics. In more detail, I need to create and attach colliders and rigidbodies and custom C# scripts to various components in the fbx. If I then go over and change the Maya scene and re-import the fbx, all this work is lost. In particular, all the collider and rigid body assignments are lost. I have to recreate and reattach everything, which I have found to be really tedious and error-prone.
So my question: Is there a workflow that simplifies this process, eliminating the need to redo so much work each time?
More detail:
I have a Maya scene with a game prop (a tree). I have "rigged" and "skinned" the tree in Maya, i.e., the tree has a skeleton and skin weights so that its branches move and bend and jiggle. In Unity, the skeleton is completely under the control of a custom C# script that does some slightly fancy physics to compute the proper AddForce()'s, etc. to make the tree shake and bend and vibrate, etc. In Unity, each Maya JOINT has a separate rigidbody, a custom mesh collider, and a couple empty game objects representing target locations for specific movements. (In FixedUpdate(), a custom C# script uses the relative locations of the tree's joints and those target locations to compute proper forces to apply.) Each time I import the fbx, I have to go through and reattach all the colliders and rigidbodies, and recreate the target locations. It's a real pain!
Answer by CHPedersen · Mar 03, 2015 at 08:32 AM
The various components applied to GameObjects in Unity such as RigidBodies and MonoBehaviours are unknown to Maya, which deals only with the Mesh, animations and materials, etc. So there is no built-in way to avoid this rework, unfortunately. However, not all is lost. :) If the setup is the same from reload to reload ( = same children, same GameObject structure, or the gameobjects created by the FBX when loaded follow at least some naming convention), you could write an editor script that handles it for you.
I.e. the editor script would instantiate a gameobject out of the raw FBX, identify which children need which components attached to them, call AddComponent on each with all applicable RigidBodies, Scripts, etc., and set the necessary values on those scripts; that is, basically automate what you do by hand on each import. When done, it could either leave the gameobject in the scene or you could have it create a prefab out of the tree, if you need one.
We have a custom script that does that to our models, since they all need the same colliders and scripts to handle mouse clicks, etc.
Very good, thanks. I hadn't known about editor scripts.
No worries, sorry I didn't add any appropriate links - info should be pretty easy to find though. :)
Have a look at this page, for example:
http://docs.unity3d.com/ScriptReference/$$anonymous$$enuItem.html
It explains how to add a menu choice to one of the editor's main menu, or the inspector's context menu. You could right click the tree FBX after each import, and have an option there called "Setup Tree Object" or something, which calls a function that automates the setup as described.
Your answer
![](https://koobas.hobune.stream/wayback/20220613184818im_/https://answers.unity.com/themes/thub/images/avi.jpg)