After the playtest, I realised that the game just suddenly restarted without letting the player know what happened. Therefore, I decided to add in a death screen where the user could either restart the current level or quit the game entirely from that menu.
In the demonstration above, when the health hits zero, an animation will play and the player’s car will be destroyed. When the user clicks “Restart” they are able to restart the level and start again, the quit button also works, but cannot be demonstrated in the unity editor.
To do this, I created a new script that would control what the buttons on the Death screen would do. I added an OnClick function and when the user clicked ‘Restart’, the current level in the build index would be reset. I added some extra lines to the health script which would show the Level Failed menu using animations. On the Text and buttons, I moved them off-screen and animated them to slide onto the screen from top and bottom, and the background I faded in using Alpha levels on the Canvas Group on the Unity Inspector.