void Update() { if (!buffersPaused) { // If user is holding the rewind key, begin reversing time. Otherwise stop reversing time. if (Input.GetKey(Keys.REVERSE)) { reversing = true; Time.timeScale = 2; player.SetIsKillable(false); } else { // This is to prevent timeScale being set to 1 before the main menu is dismissed. if (menu.isGameStarted()) { reversing = false; Time.timeScale = 1; player.SetIsKillable(true); } } // Clear the list of positions once the rewind key is let go, as we only store one rewind session. if (Input.GetKeyUp(Keys.REVERSE)) { if (menu.isGameStarted()) { positions.Clear(); player.SetIsKillable(true); } } } }