Game Development Reference
In-Depth Information
some transitions between the states along with the conditions for those transitions, as
shown in the following screenshot:
As seen in the previous screenshot, the states and their transitions are as follows:
Idle | Attack and PlayerSeen is true means attack the player when the Goblin
sees him.
Idle | Defend , PlayerSeen is true , and PlayerAttacking is true means if the
player attacks first when they are seen by the Goblin, then defend.
Attack | Defend and PlayerAttacking is true means switch to defend if the
player attacks.
Defend | Attack and PlayerAttacking is false means as soon as the player
stops attacking, switch back to Attack .
Any State | Idle and PlayerSeen is false means if the Goblin loses sight of the
player at any time, go back to Idle .
Any State | Run Away , EnemyHealth is less than 2 , and PlayerHealth is great-
er than 2 means the Goblin is basically a coward. If at any time their health drops
too low and the player is a lot healthier, it will run away as fast as its little legs
will take it.
Now that we have our AI state machine for our Goblin, select the Goblin game object in
the Scene hierarchy and add a new Animator Component in the Inspector menu and
drag the newly created animator to it, which should now look like the following screen-
shot:
Search WWH ::




Custom Search