public void Die() { if (isLocalPlayer) { PlayerCanvas.canvas.WriteGameStatusText("Respawn in " + respawnTime + " seconds"); PlayerCanvas.canvas.PlayDeathAudio(); } DisablePlayer(); Debug.Log("There are " + AIToNotifyWhenYouDie.Count + " to notify of death."); for (int i = 0; i < AIToNotifyWhenYouDie.Count; i++) { Debug.Log("Notifying " + AIToNotifyWhenYouDie[i].name); MovementAI AIToNotify = AIToNotifyWhenYouDie[i].GetComponent <MovementAI>(); if (AIToNotify != null) { AIToNotify.NotifyOfDeath(this.gameObject); } else { TurretAI TurretToNotify = AIToNotifyWhenYouDie[AIToNotifyWhenYouDie.Count - 1].GetComponent <TurretAI>(); if (TurretToNotify != null) { TurretToNotify.NotifyOfDeath(this.gameObject); } } } playerFlagHolder.DropFlags(); Invoke("Respawn", respawnTime); }