IEnumerator Rewinding() { levelStats.PauseTimer(); playerControl.DisableControls(); crosshair.SetActive(false); AddDeath(); ResetPlayer(); Time.timeScale = 0.0f; m_PostProcessVolume.isGlobal = true; // Generates a random death message that is never the same twice in a row. currDeathMessage = (currDeathMessage + Random.Range(1, deathMessages.Length)) % deathMessages.Length; diedMsg.GetComponent <Text>().text = deathMessages[currDeathMessage]; diedMsg.gameObject.SetActive(true); soundManager.PlayDeathSound(); yield return(new WaitForSecondsRealtime(deathTime)); diedMsg.gameObject.SetActive(false); Time.timeScale = 1.0f; ResetLevelObjects(true); soundManager.PlayRewindSound(); isRewinding = true; // timeWarpMultiplier = 0.001f; // SetTimeWarpEnabled(true); rewindAnim.gameObject.SetActive(true); // rewindAnim.GetComponentInChildren<Animator>().SetBool("PlayRewind", true); rewindAnim.GetComponentInChildren <Animator>().ResetTrigger("New Trigger 0"); rewindAnim.GetComponentInChildren <Animator>().SetTrigger("New Trigger"); playerControl.StartRewind(); // yield return new WaitForSecondsRealtime(3f); yield return(new WaitUntil(() => playerControl.isRewinding == false)); // Debug.Log("rewind finished"); // timeWarpMultiplier = 0.4f; // SetTimeWarpEnabled(false); EnableTurrets(); m_PostProcessVolume.isGlobal = false; playerControl.StopRewind(); playerControl.EnablePlayerControls(); // rewindAnim.GetComponentInChildren<Animator>().SetBool("PlayRewind", false); rewindAnim.gameObject.SetActive(false); rewindAnim.GetComponentInChildren <Animator>().ResetTrigger("New Trigger"); rewindAnim.GetComponentInChildren <Animator>().SetTrigger("New Trigger 0"); crosshair.SetActive(true); levelStats.StartTimer(); RestartLevel(true); isRewinding = false; }