
5. Top Down Zombie Defence
A Personal Project making a top down zombie wave shoot-em-up.
After getting a decently high level of understand of making a 2D game, I was inspired to make my own. I planned out a game in which a player must fight through hordes of zombies, explore the different rooms, find loot and upgrade weapons and statistics. I decided that I would do this on Unity coding in C#.
Because this was a personal project, I decided to start with using assets from google images and unity as stock/temporary art. Because I had made my movement code modular from my NOOM game jam project, I decided to re-use that code for efficiency. I did have a few issues with translating the code onto my new project with a few variables that I couldn’t figure out what they did. For future reference, I need to assure that code that isn’t obvious, needs to be commented and have appropriate names (most of my variables did, however, a couple left me stumbled).
Having the basic movement in, I started work on the enemies. It would be a basic, move towards the player and when close, attack. I did this using collision boxes and triggers. A challenge that I had set for this, was to use minimal tutorials/google searches, to really see what I have learnt in my first year of games technology. I found that I could confidently remember the player/enemy attack scripts and setting the collisions for them up. Here, I also made sure each entity/sprite had its suitable layer/tag to make sure the 2D Physics tree made sense, in which the player can’t move through walls/objects, whereas the zombies can move from outside the map (where they spawned randomly), into the map. I kept having issues with zombies and players collision controllers where sometimes zombies would phase through walls, or the player would have weird situations getting stuck on objects/zombies, but to fix this I went into the layer collision matrix to check what can interact with what layers. I remembered how to do this from the NOOM 2D game in which I was taught how to use this matrix, and I will continue to use this knowledge, and make sure that each suitable object in the game has its suitable layer for more sustainable code work.
Working on a store was my next big thing. I firstly made doors that teleport you to and from the shop, but did find that the player can just abuse this mechanic – if they are struggling/dying then just run to the shop where there are no enemies. So, I added a 1.5 second timer in which the player must stay inside the collision box at all times to teleport. Inside the shop I added a menu to show 3 guns you can buy which all change mag size and shoot speed. I also added the sniper to zoom the camera out and instant kill with slow fire rate. An area that I really struggled with was changing the weapon damage. Because each zombie would be instantiated from another zombie game object, it would spawn with a set health and ‘TakeDamage’ script, and for the new weapon damage to take place, it would only work on newly spawned enemies that have the new weapon damage on them. This meant that the gun would do very low damage on the rest of the round remaining. The main way I would fix this would firstly to make the zombie a prefab, and instantiate it from there, but also putting the weapon damage script on the gun itself, meaning I can change values of the gun and it’ll affect the zombies differently straight away.
I wasn’t happy with the current spawning system as it relied on the playing killing a certain number of enemies until the next zombie to spawn, but I kept encountering bugs in which the next wave didn’t start as entities killed didn’t get increased. So, to counter this, I just made a set number of zombies spawn depending on what round it is, and each round health and speed increases with also a timer in between rounds to allow the player to go to the store. I much preferred this way as it is more organized and easier for the player to understand the principles of how many zombies will spawn each round, as apposed to sometimes endless zombies on 1 round, then the next not starting.





