Very interesting day on the Core Programming front today… Ultimately, I was able to implement the enemy spawn wave feature, as required toward course completion. Here’s a brief rundown of how I did it:

  • Move enemy spawning behavior into a coroutine
  • Introduce a wave number variable, to be incremented each time a wave is finished
  • Implement a SpawnState variable, which can be set to COUNTING, WAITING, or SPAWNING
  • Utilize the existing method for spawning, and call it during SPAWNING state
  • Add a boolean check to see if all of the spawned enemies have been destroyed
  • Implement an IEnumerator to increment the wave number
line 10 is only working as type transform, not GameObject
almost there… can I instantiate a different way and still count in newEnemies.count ?

After some tinkering, I was able to get this method working very well… but with only one enemy type. I have the ability to assign the transform in Unity’s inspector, but only one type. In my previous enemy spawning setup, I had the spawn manager choose randomly between the four enemy types.

When I try to introduce an array to the enemy (either as a transform or as a GameObject), Unity throws me quite a few errors. When I try to serialize the field for the enemy (to be instantiated), it throws off my enemy count that is the lever between spawn states.

I have to do some investigating to solve the issue and be able to randomly generate which enemy type is to be spawned. But the behavior is working currently, and it makes the game quite a bit more challenging.

I’ll also be adding a text element to the UI in between waves.

Coding my future as a software developer; // if (attitude > 0) {progress ++;}