Game Development Reference
In-Depth Information
By specifying a name and the start and end frames for each specific animation
sequence, Unity can divide a single file up for easy multiple animation use.
For more details on settings in the Inspector, visit http://www.unity3d.com/
support/documentation/Manual/Animations.html .
Unity Hands On
Managing Multiple 3D Animations
Step 1. Download Chapter Three/Sequenced3D.zip from the Web
site and open the SingleAnimFile scene. In it you will find the Lerpz
model. If you play, at this point, the model will play through all the
animations in the file as they have not been specified individually in
the import settings.
Step 2. Select the Lerpz model in the Project. In the Inspector locate
the individual animation section of the FBX Importer component.
Step 3. Add two animations as shown in Figure 3.19 . Add a walk
animation with starting frame 1 and ending frame 33 and a jump
animation with starting frame 121 and ending frame 129. Click the
Apply button at the bottom of the Inspector view.
FIG 3.19 Adding two animations to
the Lerpz character.
Step 4. Create a JavaScript file called controls.js and open with the
script editor. Add the code shown in Listing 3.21 .
Listing 3.21 Controlling Animations with Key Presses
function Update ()
{
if(Input.GetKeyDown("left"))
{
this.animation.Play("walk");
}
else if(Input.GetKeyDown("space"))
{
this.animation.Play("jump");
}
}
Search Nedrilad ::




Custom Search