IEnumerator ProcessDeathAnimation(float delay) { GameObject pacMan = GameObject.Find("Pacman"); pacMan.transform.GetComponent <Animator>().enabled = true; pacMan.GetComponent <AnimationController>().SetAnimatorState(AnimationController.State.DEAD); yield return(new WaitForSeconds(delay)); pacMan.GetComponent <SpriteRenderer>().enabled = false; if (Lives.pacmanLives <= 0) { readyText.GetComponent <Text>().text = "GAME OVER"; readyText.GetComponent <Text>().color = new Color(153f / 255f, 0, 0); readyText.GetComponent <Text>().enabled = true; StartCoroutine(ProcessGameOver(2f)); } else { readyText.GetComponent <Text>().text = "READY!"; readyText.GetComponent <Text>().color = new Color(1, 1, 0); readyText.GetComponent <Text>().enabled = true; float songDelay = audioEngine.AfterDeath(); StartCoroutine(ProcessStart(songDelay)); } }