Comments

  • The StateAttack coroutine begins and remains throughout the Attack state.
  • The Transform.LookAt function is called during the coroutine loop, on each frame, to reorient the enemy to always face the player character.
  • If the enemy falls outside the Attack distance, he reverts to the Chase state to catch up with the player. The distance between player and enemy is determined by the Vector3.Distance function.
  • If the zombie reaches StoppingDistance from the player, they stop moving and continue to attack.

The Attack state, as it stands, is not sufficient to actually inflict damage on the player. The StateAttack coroutine, for example, contains no code to interact with the player character and therefore causes no damage for each punch ...

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.