Game Development Reference
In-Depth Information
However, it is not connected to anything just yet, as we want to play the animation when
the Goblin dies. We just need to hook this up to the
Any
state for when the Goblin's health
drops to
0
or below.
So, right-click on the
Any
state, create a new transition, and connect it to the new
Gob-
linDeath
state. Then, set the condition for this transition so that
EnemyHealth
is less than
1
.
To tidy things up, we also need to fix the transition from the
Idle
state to the
Any
state be-
cause we only want the Any state to be used when the Goblin is leaving the scene (either
in a box or as fast as his little legs will take him). This is because the Idle state is the de-
fault state and it will begin there, so we only need control when the Goblin goes into a de-
fense mode or attacks the player. To do this, we need to perform the following:
1. Remove the transition between the Idle state and the Any state.
2. Add a new transition from
Attack
to
Idle
with the condition
playerSeen = false
.
3. Add a new transition from
Defend
to
Idle
with the condition
playerSeen = false
.
This closes the loop a bit more cleanly between the action and exit states (it also stops a
bug where the state machine could hop directly from
Idle
to
Death
).
The final Goblin AI Animator view should now look like this: