Time for action – creating a loss screen
You can already exit the game by winning because we coded a collision with the cube at the other end of the level to result in the win screen being displayed. However, if the player accidentally rolls off the level, there's no way for them to get back up and try again.
To fix this, we'll create a loss screen that lets the user replay the game. The process of building our loss screen will follow our process of building the title screen, but we'll also create a trigger so that the loss screen is displayed when the marble falls off the level. Perform the following steps to create a loss screen:
Create a new scene called
LossScreen
in yourRollingMarble
project.Set your preferred background color in the Inspector window for the Main Camera object in the Hierarchy window.
Create a new GUI Text object from the Create menu in the Hierarchy window.
Set the Text property of the new GUI Text object to read
You Lose
.Set the font size of the GUI Text object to be...