IEnumerator KillZombie() {
yield return new WaitForSeconds(zombieDeathDelay); // waits for zombie corpse removal delay
PhotonNetwork.Destroy(gameObject);
Debug.Log("Zombie Died");
nm.zombieDied();
}
Trying to run this code to do a timer. However, the code never acutally runs.
ZombieDeathDelay = 5f;
You need to start the coroutine. There are 2 ways.
StartCoroutine(KillZombie());
and
StartCoroutine(āKillZombieā);
The latter allows you to call StopCoroutine(āKillZombieā); as the other one does not.
1 Like
How would I make it stop as soon as the zombie dies?
function OnDestory() {
StopCoroutine(āKillZombieā);
}