January 2015
Intermediate to advanced
380 pages
8h 32m
English
If the player is seen by the enemy and is not within attacking distance, the enemy would run to attack the player. This state, in which the enemy runs towards the player with hostile intent, is the Chase state. There are two main exit conditions for this state. If the enemy reaches attacking distance, they should change from the Chase state to the Attack state. In contrast, if the player disappears from sight, the enemy should continue to chase as best as they can for a while and then give up the chase if, after an interval, the player still cannot be sighted. Refer to the following code sample 7-9:
01 //This coroutine runs when object is in chase state 02 public IEnumerator State_Chase() 03 { 04 //Set current state 05 ...Read now
Unlock full access