
Things just got tough for our player. We’ve given the enemy something new. The funny thing is, it’s not a new weapon. It’s just the ability to spawn from the side and move left to right instead of top down. It’s almost weird just how hard that suddenly made things.
Now admittedly, I did double the number of enemy spawning because I have yet to spend time tuning it. But even so, my first play attempt and I was three hits and dead within seconds. The mere fact the enemy objects were coming from two sides at once was quickly overwhelming. It will be even worse when I allow them to come from the right side as well.
At this point, the game is not playable. To just establish the new enemy behavior, all I did pretty much was copy-n-paste code to make separate methods and add a switch statement or two. This proved the point, but as I mentioned, resulted in doubling the number of enemy ships spawned. I’m okay with that for the moment because I know what is coming next and that is creating an actual “wave” logic to the game play. This is where I will take the time to balance it out.
At the moment, I see two basic approaches to creating this balance and wave system. One, is to use a single spawning loop and have it switch between objects to spawn. The other is to create several spawning loops and balance each individually. Visually, I think of the first option as balancing a ceiling fan. You have several blades, each that needs balanced but the whole thing only goes in one direction. All you can do is vary the speed. The second I see as being something like a juggler. You can juggle anything, and each object can actually be thrown in a different direction. I’ve done both in my code so far. My enemy ships are spawned through two different coroutines, each operating independently. My power ups however are spawned from a single coroutine using a random number range for each power up to establish an approximate percentage of how often each is instantiated.
An additional question I am running though my head right now is the script and prefab for my enemy. At the moment, I am using the same enemy game object for both types of enemies. I just set an additional property to distinguish between our original, top-down enemy and our new left-to-right enemy. That property is then used in a couple switch statements to decide which method to run. I am pretty strongly leaning toward creating a new enemy prefab, just so I can keep the code clean and leave a path to create further deviations in my enemy objects later.
With that in mind, I won’t review any of the code as I normally do, since I consider it mostly throw away and since, our very next task will be far more interesting. Instead, I’ll leave you with my dramatic, three-way hit death scene. I think I literally got hit all three ways I could all at once. Once from laser fire, once from collision with a top-down enemy and once from collision with a left-to-right enemy!

