MayaCE3 Tutorial 2: Exporting animation
Now that we’ve got our character into Sandbox, it’s time to export some animations. This tutorial assumes you followed precisely the previous tutorial.
In my current Maya scene I have:
- The master skeleton, which is the animation rig (on the left).
- The slave skeleton, which is the actual deforming skeleton to which the geometry is bound (on the right).
The slave setup is a simple FK skeleton derived from my animation rig (the master skeleton). Its joints are driven by the master skeleton’s joints through the use of parent constraints. But if you intend to do the same, make sure that the Bip01 joint (the root-joint of the slave skeleton that sits on the ground in-between the legs) is only driven by a point-constraint.
Note: The Bip01 joint should only receive translation information, not rotation nor scale!
Be aware that when you export an animation, the character itself (mesh + skeleton) will NOT be exported; only the animation information on the joints (.caf file). So you must first export the character (as described in the previous tutorial) before you export animations for it.
Note: In order for an animation to work on a character (.chr file), the character must have at least the same number of joints (named the exact same way). But interestingly it can also have additional joints!
I will now proceed to export a run cycle for my character. But first, remember that if you animated your character on the spot for ease of animation, you need to actually have the character move through space. If you forget this, the CryEngine will complain that the “animation has no speed”!
1) Define the frame rate:
The first thing to is define the frame rate at which you’re animating. In this case, since I key-framed my animation I used 24fps. MayaCE3 will convert everything to NTSC at export time, so you don’t have to worry about that.
Note: If you work at 24fps it is recommended to add a key before the first and after the last key of your animation in order to avoid a “pop” in the loop. This is due to an unavoidable artifact of the time unit conversion.
2) Create the animation clip:
Click on “Animation Manager” and click on “Create New Animation“.
Input the information regarding the animation clip you want to create. Note that if you already have exported your character before and then clicked on Save Preferences then the Path field will be automatically filled up for you.
Note: At this point it is important to realize that the …/Game/Animations directory should be a mirror of your …/Game/Objects directory. So if I have a character exported in …/Game/Objects/my_objects/mouse then I should have a similar structure in …/Game/Animations/my_objects/mouse. If this is not the case, then the animation export will fail!
Also, you need to make sure that the official Crytek Animations.cba file lives in your …Game/Animations folder. This file gets automatically updated by MayaCE3 with your custom characters/animations info.
The information you entered will appear in the list of available animation clips.
3) Export the animations:
Click on “Export Animation“. If everything goes well, the compiler window will pop up and the .caf file will be created. MayaCE3 will also take care to automatically update the Animations.cba file and the .chrparams file.
4) Check you animations in Sandbox:
Load Sandbox (or close it down, then re-open it). Then open the Character Editor and load the character. On the left-hand side, in the Animations list, your animation should be available (in that case “run”).
Just click on the animation to see the result.
In the next tutorial, we’ll deal with replacing the player character with our own custom character…