Week 4 | Session 2 - Control the Background - April 14, 2020
Tutorial
·
Beginner
·
+10XP
·
60 mins
·
(34)
Unity Technologies

We’ve got the core mechanics of this game figured out: The player can tap the spacebar to jump over incoming obstacles. However, the player appears to be running for the first few seconds, but then the background just disappears! In order to fix this, we need to repeat the background seamlessly to make it look like the world is rushing by! We also need the game to halt when the player collides with an obstacle, stopping the background from repeating and stopping the obstacles from spawning. Lastly, we must destroy any obstacles that get past the player.
Languages available:
1. Overview
This is the same content covered in Lesson 3.2 in the independent Create with Code Course.
What you will make:
- The background moves flawlessly at the same time as the obstacles, and the obstacles will despawn when they exit game boundaries. With the power of script communication, the background and spawn manager will halt when the player collides with an obstacle. Colliding with an obstacle will also trigger a game over message in the console log, halting the background and the spawn manager.
What you will learn:
- Use tags to label game objects and call them in the code
- Use script communication to access the methods and variables of other scripts
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 - 14th April - 9am PST
If you missed this live session, you can catch up with the video below:
4. Recorded Live Session - 14th April - 5pm PST
If you missed this live 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 3.2 of the independent Create with Code Course
Bonus Challenges:
- Experiment with new features (after making a backup)
- Use Debug.Log to simulate a timer that counts up seconds from 0 and then stops counting when the game is over
- 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 3.3 of the independent Create with Code Course.