The Chase state occurs when the NPC is following and moving toward the player. In Dead Keys, this happens whenever the scene camera moves into a trigger volume or area where zombies are waiting:
![](https://static.packt-cdn.com/products/9781788479837/graphics/assets/2e3376f6-0629-48e2-abfc-59c75f282c72.png)
Chase state
The following is the Chase coroutine (for the Chase state). It contains some interesting features, detailed further in the comments section:
//------------------------------------
public IEnumerator StateChase()
{
//Run chase animation
ThisAnimator.SetInteger("AnimState", (int) ActiveState);
//Set destination
ThisAgent.SetDestination (PlayerTransform.position);
//Wait until path is calculated
while (!ThisAgent.hasPath)
yield return null;
//While in chase state
while(ActiveState == AISTATE.CHASE)
{
if (ThisAgent.remainingDistance <...