YAMR: All animations done

The last few days I was busy animating characters and other objects and making cutscenes for the game. And just as the title of this blog post says: "YAMR" (Yet another milestone reached). All animations for the game are done and included into the game.

Making animations

Bringing in a new animation into the game and using it involves several steps:

1. Creating the animation in Blender

Blender is the 3D modeling software I use. I developed a very complicated rig for the worms to animate them, which contains four important parts:

  • A control rig that has control points that are used to make the animations. These control points are the only objects that are touched or changed when animating.
    The control rig
  • A bezier curve that is controlled by the control rig. That means the control points/handles of the control rig "draw" this curve.
    The bezier curve
  • An intermediate (Spline IK) rig that consists of bones that follow the bezier curve.
    The intermediate rig
  • A deform rig that has the same amount of bones as the intermediate rig, but these bones are constrained or connected in another way. The deform rig is what finally gets exported to Unity to be used in the game.
    The deform rig

Building this complicated rig was six month of work, but it had to involve so many components to work properly in Unity.

After a new animation is done it has to be "baked" from the control rig to the deform rig. Baking means that the bone positions of the intermediate rig are copied to the deform rig frame by frame for the length of the animation. This step also transforms inverse kinematics to forward kinematics. This may be a bit technical but if you want to know more about rigged animations, forwarded and inverse kinematics there are a lot of sources all over the internet. It would go beyond the scope to explain all the involved technologies here.

2. Importing the animation into Unity

After exporting the new animation from Blender it has to be imported into Unity. That step is very simple and forward. Just copy the animation file over to the project, change some import options and done.

3. Programming the Animator Controller

For an animation to be used by the Unity Engine or by a character to be more specific it has to be programmed into a so called Animator Controller. This is an animation state machine that code of the game to let the worm do the fancy things the do. You can imagine it as a completely seperate program that runs in the background that handles all the animation stuff: Playing an animation, blending from one animation to another and other things. The Animator Controller contains many layers and so called State Machines and Blend Trees. This is how the base layer of a character Animator Controller looks like:

The Animator Controller base layer

On the left you see a list of parameters which are used to control the animations from code. Those parameters can be of different types such as Boolean, Integer, Trigger and others. The first parameter "MoveSpeed" for example is of type float and controls if the character stays still (Idle state), walks or runs, dependent on the value of the parameter. A value less than 0.1 means the character plays its idle animation. A value between 0.1 and 2.0 lets the character walk with the speed set by the value. A value greater than 2.0 lets the character "run".

And this is just the layer with only the one-shot animations:

The Animator Controller one-shot layer

This is the layer for loops and states:

The Animator Controller loops and states layer

And yes, there are more layers and there are layers that control different body parts to make a character shake his head while walking for example. It's very complex.

4. Using the animation in Adventure Creator's visual scripting system

Once all preperation is done it is quite easy to fire up an animation in the game. The action "Character: Animate" for example triggers the "Take something" animation based on the position I give it:

Scripting in Adventure Creator

Animating a character

Posts in this Series