Fun idea. Going back only ONE level on death and looping your first level

So instead of dying and starting from the very beginning i decided that on death to go back one level only so it would be less frustrating for players and then if youre on the first level to loop back to it the same kind of way Ben showed us.

private void ReturnFirstLevel()
    {
        int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;

        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1);
        if (currentSceneIndex == SceneManager.sceneCountInBuildSettings - 6)
        {
            SceneManager.LoadScene(0);
        }
    }

Privacy & Terms