Game Development Reference
In-Depth Information
Objective Complete - Mini Debriefing
We just added a new script to check what the animaion clip should play when the character
is in each acion. We also set the speed of each animaion by using
animation[name].
speed
, set the
warpMode
by using
animation[name].warpMode
, and we used the
animation.CrossFade(name, time)
to blend one animaion clip to another.
Classified Intel
In this step, we set the speed of our animaion by using
animation[name].speed
, where
animation[name]
is the animaion clip that we have already set up in the irst step.
The
speed
parameter is basically the speed with which the animaion clip is played. For
example, if we set our animaion from 3D Sotware to play this animaion in one second,
and we set the speed of this animaion equal to
1
, then the animaion clip will play at the
same speed as the source animaion. On the other hand, if we set up the speed to
2
, this
animaion clip will play twice as fast as our source animaion. Also, if we set the number
lower than
1
, the animaion will play that many imes slower than the source.
The
animation.CrossFade()
funcion will cross fade from the current animaion clip
to another animaion, and we pass its name to this funcion. We can also control how
much ime we want to cross fade for by seing the number of imes. More details on
this funcion are available at:
http://unity3d.com/support/documentation/
ScriptReference/Animation.CrossFade.html
.
Creating a third-person camera to
follow our character
From the last secion, we got the controllable character with the animaion, but the camera
isn't actually following the character at all. So, in this secion we will create the third-person
camera to follow our character.
Prepare for Lift Off
Create a new JavaScript in
Unity
by going to
Assets
|
Create
|
JavaScript
, and name it
CharacterCamera
. Then right-click on this script and click
Sync MonoDevelop Project
(or
double-click it if we already set
MonoDevelop
as our main editor; if not it will open the
default script editor, either
Unitron
or
UniScite
) to open
MonoDevelop
. Now we are ready
to code.