Login Form

3D Action Adventure Kit Character Animation


What this document will be covering

This document will be covering everything to do with creating your own character model and moving it from Maya into the Torque Game Engine with working animations! It will be using the default Maco character model as the basis for which to learn from so that you may either modify him, or create your own character.

Note: This documentation is specific to TGEA, not the newest T3D build. Most of the workflow is still relevant but specific lines of code called out or editor shortcut keys may no longer be relevant.

What this document will not be covering

This document will not be covering how to model, rig, or animate in Maya. While there is explanation of the source files we have included with the kit, it will not be speaking in detail to the creation process of these assets. That’s for you to learn on your own from other resources. However, this document will be focusing on the Torque specific workflow. While there are plenty of free and paid tutorials on modeling, animating, and rigging, we found that there’s a lack of documentation and example files regarding robust character animation in Torque, particularly if you are a Maya user.

Information Model

Please take a minute to look at the information model accompanying this documentation. This model outlines the entire process of taking a 3d character from Maya all the way to in-game. We wanted to present all of this information in one big model so that you may see the entire process at once and how each step relates to the other. It may be useful to have this open while you read through this document to give you an idea of the big picture of the entire process.

The Character Model

First let’s start off with a tour of the existing character model: Maco
From our past experiences, studying existing functional systems is one of the best ways to learn how to modify and create your own. For this reason we will start with looking at how the Maco character is set up. Using this information you will be able to modify his existing animations into your own, or you will be able to create your own character to run, jump, and climb around the world you’ve created.

Open the Maco Maya file found in art_source_files/player_source_files/. Upon opening you will see several different elements:

Textured 3D Mesh
The Maco character mesh is made up of 6 separate triangulated meshes. All of these separate meshes are bound to the underlying bone structure. The mesh also uses 2 textures: One for his entire body, and 1 for his face.

You can see that underneath the mesh there is an extensive bone structure in place. This bone structure is the engine powering the mesh when you animate.

Note: If you create your own skeleton, ensure all the bones have unique names. If there are any bones that have duplicate names you will have troubles when importing your character into ShowTools or the game engine. Maya will not warn you about this so you have to make sure you remember this.


maco_curveskeleton.jpgAnimation Rig (NURBS Curves)
To make animating easier, what many professional 3D animation studios do is create an animation Rig comprised of curves and controls. Think of the NURBS curves as little icons that you can grab and manipulate your marionette with. They are there to make things easier. These curves power the bone structure and it is the curves that are animated and key framed, not the bones themselves. In addition to making things easier to animate, a handful of other useful tools such as constraints, IK handles, expressions, driven keys, and clusters are added in, and controlled by the curves or included as attributes in the curve that can be accessed via the channel box.

Additional attributes such as the ability to open/close the characters fist, or roll his foot forward have also been added to the Maco curves to make animation easier.

Remember: you should always animate the rig curves and never be animating the bones themselves.

If you do not know how to rig a character using curves we highly recommend that you take an afternoon to learn. It doesn’t take very long to learn the basics and it will save you countless hours in the long run.

As you start to experiment with the rig you will notice that sometimes you cannot rotate, or move a curve in the way that you want to. That is because we have removed the ability to do anything that you shouldn’t do with that body part. For example, you cannot move the head up and down because that is not the way a head works in real life. In real life you would either rotate the head or bend the spine to adjust the position of the head. By removing the ability to rotate or translate certain body parts, the rigger is attempting to minimizing the amounts of errors that will cause the rig to act in ways that would not be natural for that body part. Maco’s rig is mimicking a human body and therefore, the physical constrains of a human body have been used as the basis for our rig.

Standard DTS Export Groups
Of course with any .dts model you have your standard export groups such as base01, start01, detail1, and the bounding box. If you do not know what these are please refer to the Torque Developer Network Wiki where there is an explanation of all the required export nodes for a .dts model.

The Rig

Maco’s Rig
Let’s take a few minutes to go over the rig so that you can start playing around right away. The rig is made up of the following curves:

Maco (master root)
If you want to move the entire Maco rig and model in the Maya scene, this is the curve to use. It is called the master curve because everything is parented to it and it is the top of the heirarchy.

LFoot/RFoot (left/right feet)
Controls the feet. There are built in IK Handles (Inverse Kinematics) that create a relationship between the hip, knee, and foot. This relationship allows you to move the foot and the knee will bend. This makes animating motions such as runs and jumps much easier.

If you select one of the foot controls, you will also notice that in the channel box there is an extra attribute called “Foot Roll.” If you click on this and middle mouse drag left or right in the viewport you will see that this foot roll attribute controls a mini rig that’s controlling how his foot behaves. This mini rig is called a Reverse Foot Rig. The minimum value of this Foot Roll attribute is -5 and the maximum is 10. Try playing around with it to get an idea of how it is controlling the foot.


Rhand/Lhand (left/right hands)
Controls the hands. The hands are set up with an IK Handle system just like the feet are. As you move the hand the elbow will rotate as necessary and you can use the elbow controls for further control. In the hand there’s also a “Fist” attribute that controls the characters fist from opening and closing. The minimum value is 0 and maximum value is 10.

Note: It is possible to have finer control in your rig to control each individual finger but we had no need for this extra dexterity. We just wanted to let you know that it is possible to add it into your rig if you would like to.

COG (center of gravity)
The center of gravity curve controls the pelvis of the character. You may notice that if you move your pelvis that many other parts of your body move with it. For this reason the COG is a parent to the following parts: spine, elbows, backpack, and knees.

Spine_ctrl (spine)
The spine controls the twisting and leaning of the upper half of Maco’s body.

RElbow/LElbow (left/right elbows)
The elbow controls will assist you in bending the arm the way that you want. The IK that controls the arms doesn’t always bend the arm in the way you want. These elbow controls will give you the ability to control in which way the arm is bending.

Backpack_ctrl (flap)
This controls the flap of the backpack. It has an expression that links the rotation of the control curve to the rotation of the flap bone structure. Play around with it and you’ll better understand how it works.

Bp_move (bag)
This curve controls the up/down and forward/back rocking of the backpack.

Rknee_ctrl/LKnee_ctrl (left/right knees)
These knee controls act in the same way as the elbow controls. If the IK isn’t bending your leg correctly, you can use these knee controls to correct it.

Head_ctrl (head)
Controls the head. In addition to the head, there are two attributes called “Lears” and “Rears.” These control the animation of the ear flaps on Maco’s hat. The minimum value is 0, and the maximum value is 10.

Rclavicle_ctrl/Lclavicle_ctrl (left/right clavicles)
The clavicle in a human skeleton allows you to push your shoulder forward, back, up, and down. Take note that it can only be rotated and not translated.

 Sidepouch_ctrl (side pouch)
This controls the small side pouch on Maco. It can only be rotated.

Tip: To make animating even easier, turn off all of your selectable objects and only turn on the ability to select curves. This will prevent you from accidentally selecting the mesh or skeleton. To do this, go to your status line (just below the menu bar and above your shelf) and click off all of the buttons except for the curve selection button. You want to leave that one turned on so that the only thing you can select are NURBS Curves.



Animation Flow Chart
For starting out, the below diagram illustrates the Maco animation flow chart. The arrows represent which way the animation can flow. Sometimes certain animations can only be accessed if coming from a particular previous animation (such as a stop animation can only occur if it comes after a run), while other animations have a high priority and can be called at any time such as the Death or Slide animation.


Character Animation Fundamentals
While this document is not purposed with teaching animation, here are some of the basics and things to think about when animating your model:

Save each animation as a separate Maya file – Remember to Reference!
It is important that once you are finished your final character model, any animations you create should be saved in separate Maya files. For example, for a character that has 4 animations (idle, run, walk, jump), my Maya files would look like this:

maco_player.mb – contains the maco model and rig in a t-pose with no animation.

maco_idle.mb – contains a reference of maco_player.mb and has the animation of maco in an idle position
maco_run.mb – contains a referenced of maco_idle.mb and has the animation of maco in a run cycle
maco_walk.mb – contains a referenced of maco_idle.mb and has the animation of maco in a walk cycle
maco_jump.mb – contains a referenced of maco_idle.mb and has the animation of maco jumping

It is important to use references. If you are unfamiliar with a reference in Maya, a reference is basically an import of your original model into a new scene. It contains all of the same data in the exact same form as the original file. The advantage to using a reference over an import, is that if you make a change in your original maco_player.mb file, this change will become updated in all of the animation files referencing that particular Maya file. If you imported your model instead of referencing, this automatic updating would not occur. This technique is used all the time in the film and game industry. It allows a modeler to create a low poly proxy model for the person rigging the model. Once the rig is complete the rigger can hand the rig off to the various animators. The great thing is that the modeler can be making tweaks to the model or updating textures and these changes will all become updated in all of the other files.

Animation Start/End frames
It is important to always be aware of which animations can lead into or will be leading out of an animation. For example, we know that if Maco is jumping forward in the air, he can either transition into a wall grab, ledge grab, a fall, or a land animation. Keeping this in mind we have to make sure the last frame of the jump animation and the first frames of those other animations will be able to transition smoothly into each other. Torque does a relatively good job of blending between animations but you have to make sure that the body parts are in relatively the correct spots or you are going to get some bad looking blends between your animations.

The Sequence Node Demystified
Here’s an explanation of the different sequence node attributes we used when creating Maco. Anything that I have not explained in the list we never used and left as default.

Start Frame – This is the 1st frame of the animation.

End Frame – This is the last frame of the animation.

Cyclic – Does the animation loop over and over?

Override Duration – This controls the speed that the animation plays in game. -1 means it’s off, .1 would mean the animation plays extremely fast, 2 means the animation plays slow. There’s no min or max value on this so you’ll have to play with it yourself to better understand it. We found that if we needed to speed up the animation slightly in game that we would just turn this to something like 0.8 and that would do the trick.

Ignore Ground – this one is kind of tricky. If this is turned off, it means that the animation will not take into consideration that your character is moving forward, back, left, or right in the Maya scene. We have this turned off most of the time (except for the jump animation). Note that if this attribute is turned on, you will NOT be able to export triggers.

Force Transform – by default this is turned off. Sometimes if you’re having problems exporting and your animation isn’t looking right, turning this ON might help solve the problem.

Num Triggers – this is how many triggers you have in the scene. It’s best not to touch this because as you add or delete triggers from your scene this will change automatically to reflect those changes

Trigger Frame0 – The frame number that you put in this attribute represents the frame that you would like to have something happen in your animation. We use these triggers for footstep decals and player sound effects.
Trigger State0 – Each Trigger Frame comes with a matching trigger state. The trigger state is what the code is looking for. You may have up to 32 different Trigger State’s coded into Torque. We have the following states programmed into the engine already:

1 – Left footstep sound, and left footprint decal
2 – Right footstep sound, and right footprint decal
3 – Play a rustling sound of Maco’s clothing
6, 7, 8, 9, 10 – These are all used for the ledge up animation to play separate sounds during the animation

Note: The number 0 directly after the words Frame and State only means that it is the first trigger created in the sequence (remember programmers start counting from 0, not 1). I think perhaps to avoid confusion you should think of it as being labeled “A” instead, because really that number doesn’t mean anything and it’s only internal to Maya’s Channel box. The next trigger you create will be labeled TriggerFrame1 and TriggerState1, the next TriggerFrame2 and TriggerState2, etc. Also do not think of the state values as 0 meaning off, and 1 being on. As you can see from above, all the state does is provide the code with a flag telling it to do something.


Great! So you have your model and you have your animations let’s get them ready for the game. A quick review on the different file types we will be exporting to:

A .dts model contains the actual 3D mesh of the model, UV texture information, the bones/skeleton (if one is present), detail levels, collision information, and bounding box. One exception if you are exporting a model for the sake of using it as a player character is that the dimensions of the bounding box do not matter because the code generates its own bounding box based on code. However you still need to use a bounding box in the scene and it is still used to decide where the player is positioned inside of the in-game code generated bounding box using the Maya bounding box pivot (yes a little confusing but there will be more explanation below).

A .dsq file plays the supporting role for the .dts file. The .dts model as discussed above is the physical mesh and skeleton while the .dsq file is the animation information. All that the .dsq contains is a list of the joints (also called nodes) and where the joints are moving in 3D space.

Now instead of re-explaining how to export characters in this document, I would like to point to a great resource on the Torque Developer Network authored by Amr Bekhit. The file exporting specifics are located near the bottom of the page: http://tdn.garagegames.com/wiki/DTS/Maya/Creating_a_Simple_Character

Note: Only those with licensed copies of Torque will be able to access these tutorials.

IK Baking

IK Baking is a step required if you are using curves to animate your model or if you are using IK.

Time to stick those bones in the oven…
Since we have been animating the rig curves this whole time, none of the bones have any key frames. Not to worry there’s a simple procedure called baking that will take the bones and “bake” the positing of the bones so that in essence your bones will now have key frames just like your curves.

Note: You do not always need to bake the bones if you are using a simple rig, or just animating the bones directly. If you are using a rig such as this one and you have IK controls, then you will need to do this step. Otherwise your animation will not play correctly in the game.

To bake your animation data into the bones you will need to:

  1. Select the root node of the skeleton
  2. Select the entire hierarchy by typing select-hi; in the MEL script command prompt.
  3. Go to Edit>Keys>Bake Simulation Option Box (the little square beside the word Bake Simulation)
  4. Make sure the settings are the same as shown below in Figure 1.
  5. Click the Bake button.

 Figure 1

Now all of your bones will have key frames in them.

A Few Extra Things You Should Know

Here are a few miscellaneous items we thought should be covered:

Cam Bone
You may have noticed that inside the start01 group alongside the Roots bone hierarchy is a bone labeled Cam. What this bone does is allow us to control where the in-game 3rd person camera is looking. We are also able to animate this Cam bone to give the camera some life. We have added subtle animations to give it a soft “hand held” feel. You will be surprised how much the animation of the camera and where the camera is specifically looking at can add to the game. Conversely a poorly animated camera or a camera that does not look at what it should be looking at can very quickly detract from your game.

Tip: If you want to create a more turbulent hand-held type of camera, try constraining the Cam bone to the root bone of the skeleton. Remember to bake this Cam node as well and remove the Constraint node from your outliner. If you do not remove the leftover constraint node it may cause you problems later on such as inconsistent data between .dsq files.

Bounding Box
As I previously mentioned I said that the size of the bounding box for the player doesn’t matter when creating player controlled characters because the code uses its own bounding box. So why do we have to put a bounding box in the animation then? Well what the bounding box does is helps you position the player relative to all of your other animations. The bounding box pivot point is used as a reference between .dsq files to position the model in the torque game engine. For example, if you have the pivot point of the bounding box in Maya directly underneath your player model in the idle animation, but for the run animation you have the bounding box pivot 10 meters in front of the player model, when Torque blends between the two animations, you will notice the player blending backwards to make the relative distance between the bounding box pivot the same as the previous animation.

To make things simple, the bounding box is used to position the player. If the player seems to be shifting when blending between animations you will most likely need to adjust the bounding box so that it is in the same relative position across all animation files.

Previewing in ShowTools
Previewing your model in ShowTools will allow you to quickly switch between animations to see how the blends look. If you want to open up your model with all of your .dsq animation files click on the Load DTS & CS button in ShowTools and you will be able to watch the transitions between your different animations by either using the “Thread Controls” or by picking out your animations from the Sequences Drop Down Box which is located to the left of the time slider.

Note: If you open up your player model using the Load DTS & CS button and you cannot see any sequences listed in the box, the reason might be because one (or more) of your .dsq’s has inconsistent nodes from the rest of the dsq files. For example, if you have a Cam node in every one of your .dsq sequences but you accidentally deleted it from one sequences, then when you open your player in ShowTools, it will not show any sequences in the drop down and you will have to go through every .dsq to see what the inconsistent element is. This is a good way to make sure that all of your files are consistent.

The player.cs file located in the same directory as the player.dts model (don’t confuse this one with the player.cs file located in the scripts directory) contains a datablock that the code uses to create the player object for the game. Each line in the file hooks up a .dsq animation to a particular action.