Maya rigging setup for Unity
I'm writing an autorigger in Python for Maya to create game rigs for Unity. I come from the cinematic world, and I am aware that some of the rigging methodologies for cinematic rigs don't work well with game rigs.
My workflow is as follows: I have a Bind skeleton that is skinned to the mesh. My script creates a separate Control rig with control joints (IK and FK), controls and other deformers that manipulate the bind skeleton. The bind skeleton joints are connected to the relevant control rig joints.
I have a few questions that I hope you could help me to setup my control rig:
1. Stretchy limbs - Can I use the scale channels to stretch the limbs or should I use only the translation ones to do so? This is particularly relevant to creating a stretchy spine using a spline IK setup and streching the joints based on the length of the spline curve. I read some conflicting information on the subject, and I would appreciate some clarification.
2. Connecting Bind skeleton to Control rig - What would be the most efficient way to do so, based on the fact that the animations will be baked out? Should the Bind skeleton be connected via constraints (orient, point/parent for stretch based on translation, scale)? Can I use direct connections, for example blendColor nodes to drive the translations and rotations of the Bind skeleton?
3. Primary joint orientation - Is there a preference for Unity? Maya's default is X-down. I find it more logical to use Y-down, with X as secondary axis and secondary world orientation
4. T-pose vs. A-pose - I see a lot of game models in the standard T-pose. The main advantage is that this pose allows for any character to fit a standardized skeleton vs a relaxed, A-pose. On the other hand, when it comes to binding the mesh, you get unwanted deformations and stretching especially on the shoulders, clavicles, upper torso and arms. Now, it's obviously a lot easier also to build a rig in the T-pose, where there's less chance of encountering strange rotations, especially when IK setups need to be on a flat plane. My question is: Would it make sense to 1)model the mesh in a relaxed pose, 2) create a standard T-pose Bind skeleton, 3) save keys on frame 0 for all Bind joints, 4) rotate the joints to match the relaxed pose, 5) skin/weight paint the mesh to the Bind skeleton and 6) reset to frame 0 in order to apply the rig back as a T-pose?
5. Facial rigs - The 64-million dollar question: joint based vs. blendshapes? How well does Unity deal with blendshapes these days? Any advantage of one over the other for game rigs?
I appreciate your comments. I'm sure a lot of people encounter similar issues and hope these questions could answer theirs as well. If you can also explain the logic behind your answer, that would be great!
Here's a partial answer off the top of my head:
1) Squash will be require work on your part. Unity does not support segment scale compensate, so you will need to reimplement it in your rig without using the flag in Maya.
2) Don't send the control rig to Unity at all, just send the deformation skeleton. It's easy to filter it out by using export selected. You can force the bake using FBX's options. Constraints or DCs are both fine, they will be baked out at export time either way. There is nothing Unity specific here, it's plain vanilla FBX.
3) Unity animations are stored as matrices, so joint orientations don't matter much. The only thing to watch for is Euler flips in the baked data coming from Maya - but that is a Maya problem, not a Unity one.
Thanks for the replies, Theodox.
To clarify, the Control rig isn't going to Unity, only the Bind skeleton with the skinned mesh.
In regards to the stretchy joints, I did a couple of tests earlier and found that a stretchy spline IK does work after baking the animation on the Bind joints. Same with stretchy translations on the leg joints (done with blendColor nodes).
I'll do more tests for the stretch, and post here.
I remember reading somewhere that Unity's legacy animation system does support bone scaling, but Mechanim has some issues with it. Might be worth checking out both systems before you go ahead.
Also, I think you might find this article really interesting- it deals with adding some run-time elements into a rig in unity for deformation systems such as twist bones etc:
I know the thread is a few months old but I have something to add to it which might be helpful to anyone doing a search on the topic.
if you export your skeleton to unity I'd highly recommend staying away from joint scaling (especially for stretch setups). Because by default maya joints have a feature activated which is called segment scale compensate. what it does is basically countering the scaling from a parent joint on a child joint giving you a super easy way to setup stretching, however no other dcc package nor engine does this.
if you need to use joint scaling turn it off and you'll get the correct results in maya as well.
Yeah, for most cases of doing simple quick stretch, we just use translateX of child joints (or Y in your case if you choose that as your down axis) and then if there's a character that needs to have scaling for puff up kind of things, to avoid the segment scale compensate and compression issues, we just make sure in the export skeleton, those joints don't have children. We use constraints, so that makes it nice and easy. One trade-off with that though is that interpolation between animations and poses will happen linearly so that can cause issues.
Also for the a-pose vs t-pose thing, in my system, I have "bind pose" rotations defined during the skeleton creation phase of the rig as custom attributes on the joints. That way, they are stored to easily be assumed during the skinning or in the control rig via a button, but if zeroed out, will go in to t-pose, so you can have the clean ik control rotations of t-pose with the better deformation of a-pose.
Last edited by nalzay; 02-08-2015 at 07:50 PM.
Beware of the Axis. Unity is based on the right-hand Axis system, but Maya is left-hand. Sometimes it annoys a bit. e.g : Exporting the camera from maya and import into the unity based on .fbx (of course the camera from maya will be just analyzed as a null locator in Unity), u might engage that. I'm not quite sure whether that matters more, just do notice it.
not a jedi yet
now that is a useful bit of tribal knowledge.
Originally Posted by fleity
We are a Max studio and our results with spline ik and scaling have been good so far...
perhaps this Maya detail is why scaling turns up problematic for others