How to Create a Game Over Screen in Unity

Load another scene when the player loses the game

Rusben Guzman
2 min readSep 11, 2021

Objective: Create a new scene and load it when the player dies

First I create a new Scene with the same background image, I added some text elements to show the game over message and the score. Also I added some buttons to play again and to go to the main menu.

In the boss script I create some text variables to get the reference to the UI text elements in the scene. In the start function I assign the respective score to each element getting the values from the player prefs and check if the current score is greater than the best score to update the best score.

In the same screen I create 2 public functions to load the game and the menu scenes.

In the Unity editor I selected each button and called the functions to load the scenes in the OnClick section.

In the game manager screen in the GameOverFunction I load the game over scene.

And that’s it!!! A completed functional game over screen.

--

--

Rusben Guzman
Rusben Guzman

Written by Rusben Guzman

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.

No responses yet