Waves Part 2
Continuing from Devlog #6, I added the homing system to the other enemy types. Now, all four enemies can randomly spawn from any spawn point. I also made the next wave text easier to see.
The only part the gif above does not show is a spawning bug after wave 1. As you can see, enemies spawn fairly often, but after wave one, they slow down a lot. It took me a while to figure out what was wrong, and yet it was so simple.
The image below is the code responsible for letting the next wave spawn. I pinpointed the bug on line 47. Initially, the enemy spawn timer is set to one second. One enemy per second. Once line 47 fires, I thought it was telling this timer to pause for three seconds, and then resume. In reality, it was resetting the spawn timer to a three-second delay, instead of a one-second delay.
This was when I realized I needed to redo the wave system. I felt the way it was written would not allow for a proper wave spawning system to work. It sucks because I'm excited to be making progress, but this is how the cookie crumbles sometimes.
I'm learning that this is just a part of the development process. You spend time implementing something, and when it works it's the greatest feeling a developer can have. But, sometimes it isn't what you think it will be when it's done. With that being said, I need to find a better long-term solution.
A New Wave System
I remembered seeing a few other tutorials on Waves when searching, so I decided to try one of them out. It was a tutorial for wave spawning in a 3D game. When I initially saw it, I overlooked it as it wasn't 2D-related. But on second thought, I figured the code should still work the same way.
While I was watching the video, small issues popped up. I noticed that the video is 2 years old, an older version of Godot was being used. Since I'm using Godot 4, some functions have been renamed/changed. I did run into some bugs and errors along the way and I will admit I was stumped for some time. These problems never deterred me though, only slowed me down.
I spent about an hour troubleshooting until it happened. The first wave of the new system was finally working.
This tutorial was hands down the best one I've seen so far. It allowed me to learn a few new tips and tricks. It also helped me build a modular system for unique waves. Each wave has it's own number of enemies, and delay between each spawn.
Wave 1 has 5 enemies with 1 second between each spawn. Wave 2 has 50 enemies with 0.5 seconds between each spawn. I also temporarily disabled the UI text for waves. That is something I'll also have to fix later.
Heres what the final product looks like.
‹ Previous Devlog: #6 Next Devlog: #8 ›