Week 6 | Session 3 - Game Over - April 29, 2020
Tutorial
·
Beginner
·
+10XP
·
60 mins
·
(31)
Unity Technologies

We added a great score counter to the game, but there are plenty of other game-changing UI elements that we could add. In this lesson, we will create some “Game Over” text that displays when a “good” target object drops below the sensor. During game over, targets will cease to spawn and the score will be reset. Lastly, we will add a “Restart Game” button that allows the player to restart the game after they have lost.
Languages available:
1. Overview
This is the same content covered in Lesson 5.3 in the independent Create with Code Course.
What you will make:
- When a “good” target drops below the sensor at the bottom of the screen, the targets will stop spawning and a “Game Over” message will display across the screen. Just underneath the “Game Over” message will be a “Reset Game” button that reboots the game and resets the score, so the player can enjoy it all over again.
What you will learn:
- Make UI elements appear and disappear with .SetActive
- Use Script Communication and Game states to have a working “Game Over” screen
- Restart the game using a UI button and Scene Management
2. Before you Begin
To participate in this session and follow along, you need:
- Unity 2018.4 installed
- An up-to-date project open in Unity:
- If you have followed along with us this week and have your own project ready, you are good to go!
- You can also download the instructor's up-to-date project and import it (If you don't know how to import a project, you can read how here)
If this is your first Create with Code live learning session, you can catch up by:
- Following along with the recordings of our previous live learning sessions
- Completing the same lessons in the independent Create with Code Course
*Note - it is not necessary for you to catch up, but it is recommended for an ideal learning experience.
3. Recorded Live Session - 29th April - 9am PST
If you missed this session, you can catch up with the video below.
4. Recorded Live Session - 29th April - 5pm PST
If you missed this session, you can catch up with the video below.
5. Next Steps
Get caught up:
If you were not able to finish the session along with the instructors, you can catch up by:
- Re-watching this recorded session when it is posted in Step 3 above at 3am PT (10am UCT) the morning after this session's date
- Picking up where you left off in Lesson 5.3 of the independent Create with Code Course
Bonus Challenges:
- Experiment with new features (after making a backup)
- When the game starts, program a “3, 2, 1, Go!” countdown to appear in the middle of the screen before objects start spawning
- Program click-and-drag swiping functionality instead of clicking, including generating a trail where the mouse has swiped
- [Difficult] Program “High Score” screen functionality on the game over screen
- Look ahead to the next lesson
- If you want to go ahead and preview what we'll be covering in the next session, you can give it a try in Lesson 5.4 of the independent Create with Code Course.