Challenge 4 - Scripting Soccer
Tutorial
·
Beginner
·
+10XP
·
60 mins
·
(22)
Unity Technologies

Challenge Overview:
Use the skills you learned in the Sumo Battle prototype in a completely different context: the soccer field. Just like in the prototype, you will control a ball by rotating the camera around it and applying a forward force, but instead of knocking them off the edge, your goal is to knock them into the opposing net while they try to get into your net. Just like in the Sumo Battle, after every round a new wave will spawn with more enemy balls, putting your defense to the test. However, almost nothing in this project is functioning! It’s your job to get it working correctly. As you do so, you will combine what you have learned about test scripts, exploratory testing, and bug reporting and practice all three throughout the challenge.
Challenge Outcome:
- Enemies move towards your net, but you can hit them to deflect them away
- Powerups apply a temporary strength boost, then disappear after 5 seconds
- When there are no more enemy balls, a new wave spawns with 1 more enemy
Languages available:
1. Overview
CWC_U4.C4_T1_v02
- Open your Prototype 4 project
- Download the "Challenge 4 Starter Files" from the Tutorial Materials section, then double-click on it to Import
- In the Project Window > Assets > Challenge 4 > Instructions folder, use the resources as a guide to complete this challenge
2. Practicing QA Skills
For this challenge, combine what you have learned about test scripts, exploratory testing, and bug reporting and practice all three throughout this challenge:
- Read through the challenge and create a test script.
- As you work through the challenge keep exploratory notes,
- As you work through the challenge catalog, tag and prioritize bugs.
3. Hitting an enemy sends it back towards you
When you hit an enemy, it should send it away from the player
- Hint: In PlayerControllerX.cs, to get a Vector away from the player, you should subtract the [enemy position] minus the [player’s position] - not the reverse
4. A new wave spawns when the player gets a powerup
A new wave should spawn when all enemy balls have been removed
- Hint: In SpawnManagerX.cs, check that the enemyCount variable is being set correctly
5. The powerup never goes away
The powerup should only last for a certain duration, then disappear
- Hint: In PlayerControllerX.cs, the PowerupCoolDown Coroutine code looks good, but this coroutine is never actually called with the StartCoroutine() method
6. 2 enemies are spawned in every wave
One enemy should be spawned in wave 1, two in wave 2, three in wave 3, etc
- Hint: In SpawnManagerX.cs, the for-loop that spawns enemy should make use of the enemiesToSpawn parameter
7. The enemy balls are not moving anywhere
The enemy balls should go towards the “Player Goal” object
- Hint: There is an error in EnemyX.cs: “NullReferenceException: Object reference not set to an instance of an object”. It looks like the playerGoal object is never assigned.
8. Bonus: The player needs a turbo boost
The player should get a speed boost whenever the player presses spacebar - and a particle effect should appear when they use it
- Hint: In PlayerController, add a simple if-statement that adds an “impulse” force if spacebar is pressed. To add a particle effect, first attach it as a child object of the Focal Point.
9. Bonus: The enemies never get more difficult
The enemies’ speed should increase in speed by a small amount with every new wave
- Hint: You’ll need to track and increase the enemy speed in SpawnManagerX.cs. Then in EnemyX.cs, reference that speed variable and set it in Start().