Unity Animation Pipeline From Maya (Part 1)
This post is my first full-fledged tutorial, so I thought I would tackle a common question I hear from new game projects. If I missed a step or if anything is unclear, please let me know so that I can address it ASAP!
Before we go into the details, I want to paint the picture of what the end goal of this tutorial is. That way, at a glance, you have an idea of what I am running you through.
To set up applications and files with the proper scale, orientation and speed to minimize fiddling in-engine.
To have exported animation and model FBX files inside the Unity directory ready to be constructed into a prefab for game use, placement and code hookup.
To have a clean, manageable naming convention and folder structure for easy updates and file handoffs between team members.
1 Base Rig File (Maya) – A Mesh\Rig with its associated Joints, Controls and Skinning information. (See Important Terms)
X Animation Files (Maya) – Any number of animation files that reference the Base Rig File and are fully animated. (Being fully animated is not a requirement, but some amount of animation is handy for confirmation of the process)
2 Folder structures – Mirrored for consistency
1 Base Rig File (Maya) – Properly named and Setup
X Animation Files (Maya) – Properly named to utilize Unity auto naming
1 Base Model File (Unity FBX) – Exported from the Base Rig File. Contains the Mesh, Joints and Skinning information only.
X Animation Files (Unity) – Exported from Maya Animation Files. These Files contains ONLY the joints and keyframe information for the animation.
Skeleton, Joint, Bone – Often these words are all used to describe the same thing, the structure in which a 3d model articulates around to create motion for animation. To get a bit more specific; A Joint or Bone is an individual piece of a Skeleton that makes up the entire structure of an articulated 3d model.
IE the “Hip Joint” or “Hip Bone” of your character has been moved too far to the side and distorts the model.
Could also be thought of as the armature or framework of the character model.
Rig – This is the structure that goes over the skeleton that the animator interacts with to make the character move. A good rig contains loads of shortcuts and features that allow animators to work quickly and is also easy to add features to.
—The Rig(Controls) and all of its transforms should never be exported into the game engine.
Freeze Transformations – The act of setting all the transforms to zero but maintaining their axis orientations. Freezing Transformations is a Maya only function and helps to debug in the engine when all of the transforms start at zero.
Skinning – An odd name admittedly, but the term itself refers to the process of “binding” or attaching a polygon model to the “joints” or “bones” so that when they move, the “skin” or model moves with them.
Source Directory – A directory structure that contains the “source” used to create the in-game files, which can be Maya, Photoshop, or 3ds max files.
Project Directory – A directory structure that contains the “in game” files, or the files that the engine is going to use or control.
Prefab – A unity only file with the extension “.prefab”. This file is used to link animations, materials, and custom Unity scripts to game logic.
Meta File – This is a file that contains unity specific project settings. When the “Use Meta Files” option is turned on, a Meta file gets created for every object inside the Unity Assets folder. It contains editor specific settings and options for each asset as well the GUID for that file.
GUID – This is a unique alphanumeric identifier that gets assigned to every object inside the Asset folder of the project. It is stored inside the Meta file and is what Unity uses to lookup and reference assets. If the GUID of an asset ever changes, anything that was referencing it will no longer be able to find it.
Dealing with scale is by far the MOST important thing while setting up files. I cannot tell you how many times I have had to go back through hundreds of files to properly set-up and unify a scale between art packages. SET IT UP RIGHT THE FIRST TIME!
Unity prefers meters, so set your scale to be 1 unit = 1 meter inside Maya.
Same standards apply to most 3d packages, but you may have to research a bit.
For characters, use as close to real world scale as possible IE: 1.8 – 2 meters tall (average Male height) or 1.8 – 2 Units tall.
Use the same scale for your environment models and make sure you have a reference scene with your models next to each other for comparison. The last thing you want to have to do is have to fiddle with the scale inside your game engine.
The Unit you pick should be the unit that your engine works with the best so a little research may be in order if you are using something other than unity.
In a pinch, you just want to pick a single unit of measurement and stick with it across ALL your packages so that you can have some consistency. It is not always possible to get the RIGHT scale, but as long as everything is the SAME scale, it reduces headaches in the future.
Orientation is another big one; ultimately this depends on the final Editor of your files (Unity, Unreal, Lumberyard, etc…).
In Unity, the positive Z-axis is forward, and the Y-axis is up.
MAKE SURE that you source 3d packages match this or you will get major headaches later trying to figure out why your models are flipped on import.
You should also note, that Unity is a left-handed coordinate system while Maya and Max are right handed. Without boring you with complex math details, it means this:
The implications are that when you export from Maya or 3dsMax to Unity, your X axis will be flipped once exported to Unity as shown below:
Cube Local Orientation MAYA:
Cube Local Orientation UNITY:
There are many issues that will come from this, but the main one I will cover now is to be aware that all of your Axis will be flipped going in to Unity.
Unity is set to play Animation at 60 fps.
Typical animation speed for Maya animation is 30 fps, which makes it easier to create and manage the timing of that speed. You can use either, but I suggest that you use 30 fps unless you really need the fidelity of 60 fps.
Typically fighting games use a higher framerate in their animation files because they often need to use the timing on animation for keying combos or fire off special events, so the higher fidelity is much easier to work with.
All the non-fighting games I have worked on have used 30 FPS
Maya Preference Settings:
Units, Axis, Speed
Up Axis: “Y”
Time: “30 fps”
The following grid settings will set up the display to have a grid line for every unit, which is 1 Meter in Maya and Unity.
Length and Width: 12
Grid Lines Every: 2
Maya File Content
Keep the joint hierarchy clean.
Don’t have extra transforms anywhere in the hierarchy and keep your controls separate so it’s easy to remove before exporting.
Joint Axis Orientation
Yes, these will also be flipped once exported. See Above information on coordinate systems.
This is super important: Make sure every one of your joints is oriented properly. There is an entire process for evaluating this, but the basics are:
Pick a main and secondary axis.
Point the main axis “down” the joint chain towards its child and your secondary axis should be world UP (Y in this case).
Any Joint without a child should just be oriented to the world for clarity, unless you have a specific purpose for it.
This is helpful if you ever need to control a joint in-engine. It will start at an axis aligned relative to the rest of them and will allow for easier direct control over a single axis. It’s also just a nice thing to do to keep things clean and animations easily debuggable.
Controls and Joint Orientations
Make sure when you set your controls to zero the joints end up in their default position.
This can be done by orienting an empty transform to the joint and then grouping the control and freezing transformations on that control object.
The local axis of the control will line up to the joint like below:
Center The Rig
This is one of the most painful things to try to debug later. Center and freeze your transforms on you rig above this point and you will prevent much pain in the future.
This means, the first joint in the hierarchy should be close to, or exactly like below:
Y: Can vary: If the joint is on the ground, it should be 0. If the first joint is the pelvis, then there will be some Y values in the transforms.
Reference your animations. Do NOT directly import your rigs in to your animation files
This is a Maya only feature, but it saves MASSIVE amounts of time when changes need to happen on a rig.
This means animations are referencing a “Rig” file, which contains all of the complex rigging information, and the animation files only store keyframe information.
Referencing is terrific for working with larger teams or contractors, as you can send them simple rig updates without causing them to update every animation file.
I will cover a post on how to setup your references properly in the future.
Individual animation files per move
I have been in some heated debates about this. In my opinion, every animation should be split up into its own file. This minimizes the risk of accidental screwups when editing animations.
It also reduces the risk of file corruption destroying numerous animations at once.
The End (For Now) – Stay tuned for the continuation!
This post got a bit out of hand, so I had to split it up into two posts. Here is the Continuation.
Let me know if I am missing anything or if you would like more detailed explanations of any of the topics going forward so I can add them to the list.
15 Free Unity Asset Tips
Join the community and stay up to date with the whats happening with the site!
I'll also throw in my top 15 tips for managing assets inside Unity!