Week 5 | Session 4 - For-Loops for Waves - April 23, 2020

Exercise

·

Beginner

·

+10XP

·

60 mins

·

Unity Technologies

Week 5 | Session 4 - For-Loops for Waves - April 23, 2020

We have all the makings of a great game; A player that rolls around and rotates the camera, a powerup that grants super strength, and an enemy that chases the player until the bitter end. In this lesson we will wrap things up by putting these pieces together!

First we will enhance the enemy spawn manager, allowing it to spawn multiple enemies and increase their number every time a wave is defeated. Lastly we will spawn the powerup with every wave, giving the player a chance to fight back against the ever-increasing horde of enemies.

1. Overview

This is the same content covered in Lesson 4.4 in the independent Create with Code Course.

What you will make:

  • The Spawn Manager will operate in waves, spawning multiple enemies and a new powerup with each iteration. Every time the enemies drop to zero, a new wave is spawned and the enemy count increases.

What you will learn:

  • Repeat functions with For-loops
  • Increment integer values in a loop with the ++ operator
  • Target objects in a scene with FindObjectsOfType
  • Return the length of an array as an integer with .Length

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:

  1. Following along with the recordings of our previous live learning sessions
  2. 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 - 23rd April - 9am PST

If you missed this session, you can catch up with the video below.

4. Recorded Live Session - 23rd 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:

  1. 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
  2. Picking up where you left off in Lesson 4.4 of the independent Create with Code Course

Bonus Challenges:

  • Course challenge
    • Complete the "Soccer Scripting" challenge from the full Create with Code course and share it on Learn
  • Experiment with new features (after making a backup)
    • Track the player’s score, reflecting the number of enemies they’ve defeated
    • Give the player a number of lives (maybe displayed using Debug.Log)
    • Prevent multiple powerups from being on-screen at one time and prevent powerups from spawning right on top of the player
  • Share your prototype
    • Continue tinkering with the prototype and share it on Learn
  • 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 Lab 4 of the independent Create with Code Course.
Optional Step

6. Share your Modified Challenge or Prototype

If you went above and beyond and modified the challenge or prototype from this week, take a screenshot or screen-recording and post it here to share what you made! Please also share with us some of the "behind-the-scenes" info regarding how you did it.

Please login to submit