Game Development Reference
In-Depth Information
Understanding and Planning Game Animation
Game character animation is one of the areas in which the assets from the 3D content
creation program and the game engine work together. For the typical in-game animation,
animators will take the rigged character and create cycled movements that can be activated
with in-engine scripts. These scripts control when the character's animation plays and how
the character moves as it animates. Clearly, understanding how your game engine, in our
case Unity, handles animations and movement is essential. Luckily, Unity utilizes anima-
tions similar to many other game engines, so the logic is similar across platforms.
Building Animations for Unity
As stated in the previous chapter, Unity requires animations to be created with rigged mod-
els. For the zombie, this will not be a problem as you have already rigged your character.
It is, however, important to remember for animations you would typi-
cally create by moving or rotating objects such as the opening of doors or
for environmental traps. Animations are imported into Unity when you
import your character model, as you will see in Chapter 10, “Implementing
Your Zombie in a Unity Game.” For now, understanding the import pro-
cess will help you plan the work for this chapter.
Figure 8.1 shows the animation portion of Unity's FBX importer. This
importer takes your file and converts it into the FBX file format. This
format retains UV coordinates and rigged animation information from
your 3D model and allows it to be used by Unity in games. The anima-
tion options give a lot of insight into how Unity understands the anima-
tions stored in these files. For example, the importer has users call out
the frames of animation that start and end each animation. This tells us
that all the animations must all be on one timeline rather than separated into actions, as
is possible with Blender's Action Editor (Figure 8.2).
You need to name these animations during importing. Although this seems like an
arbitrary step, these names are referenced in scripts to activate the animations, such as
the Idle() function shown here:
function Idle ()
{
animation.Play(“idle”);
// if idling sound isn't already set up, set it and start it playing.
if (idleSound)
{
if (audio.clip != idleSound)
{
audio.Stop();
audio.clip = idleSound;
audio.loop = true;
audio.Play(); // play the idle sound.
}
Figure 8.1
The animation
options in Unity's
FBX importer
}
Search WWH ::




Custom Search