Tower Defense Tutorial – Brackeys – Ep. 01, 02, 03

January 23, 2019

Tower Defense Tutorial

Episode 01 – 02 – 03

Youtube – How to make a Tower Defense Game (E01) – Unity Tutorial
Youtube – How to make a Tower Defense Game (E02 Enemy AI) – Unity Tutorial
Youtube – How to make a Tower Defense Game (E03 Wave Spawner) – Unity Tutorial

By: Brackeys
Ep. 01

Created all the nodes in grid that make up the map. Created the ground out of scaled cube objects as well. Added start and end location as simple cubes for now.

Ep. 02

Creating the enemy AI with waypoints. A static transform array was created to contain all of the locations of the waypoints. There was an issue where we got an “index out of range” error because the enemy was looking for another waypoint to go to when it was supposed to be destroyed. It was being destroyed, but since that can take the computer some time to do, it was continuing into the next lines of code before the object was completely destroyed. To solve this, a return; line was added in the if statement for destroying the object to ensure that process finished before doing the rest of the code.

Ep. 03

This was creating the wave spawner for the enemies. The spawner needs a timer to control how often and when it releases waves. The approach used here was a countdownTimer that was reduced by time.deltatime in the update method.

Enemies however were being spawned directly on top of each other all at once for each wave. Coroutines were the choice to resolve this issue. Coroutines are useful to run functions separately and side by side with the main functionality of the code.