Comments

  • The StateChase coroutine begins by setting the AnimState integer parameter in Mecanim, for playing the walk/chase animation. This is configured to play on a loop.
  • Next, the Nav Mesh Agent component is used to set the destination for the zombie. This will be the player location. This causes the zombie to move, walking toward the player, using the navigation mesh.
  • After setting the navmesh destination, the coroutine waits for the NavMeshAgent to fully calculate the zombie's path. The calculation often happens quickly, but it runs asynchronously and can take more than one frame, that is, the path is not necessarily fully calculated immediately after calling SetDestination.
  • Next, the couroutine loops continuously, frame by frame, until ...

Get Mastering Unity 2017 Game Development with C# - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.