Trouble with making a timer

    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ā€);
}