Game Development Reference
In-Depth Information
Let's now give those transition connects some information on how to act so that
rather than playing in a loop, they actually play when we want them to. Click
on
PlayerIdleAnimation
, then click on the transition, and then look over in the
inspector. The transition has some simple data that it uses to know when to go to
the connected animation. In this case, the animation simply waits until the time has
reached 1 second, then goes to the next animation--which is why this condition is
specified as
Exit Time
with the property of
1.00
. Let's change this to use our
Boolean
Walking
state instead. The
Exit Time
condition is good when you wish to blend two
animations; however, for the sake of this animation, it will simply play or not play;
therefore, Boolean. Click on
Exit Time
to reveal it as a pop up. The
Walking
Boolean
has already been listed for us; click on that. All you need to do now is make sure
that the transition going into
PlayerWalkingAnimation
has
True
as the
Walking
condition, and the transition going into
PlayerIdleAnimation
has
False
as the
Walking
condition. The following screenshot shows what the animation should
now look like:
With that completed, we can go ahead and test! Perform the following steps:
1.
Hit
Play
in the game.
2.
With the game running, select the
Player
object.
3.
In the
Animator
tab, select the checkbox next to
Walking
under
Parameters
.
When the checkbox is active, the walking animation will play, whereas when the
checkbox is inactive, the idle animation will play. It really is as simple as that.