Enemy Homing
When it came to enemy homing, I tried multiple different ways to implement this feature. Most of them did not work, until one of the few that I tried last. This was the closest attempt to having a working homing system.
An enemy is fed the towers coordinates and should travel towards it. But that didn't happen.
Enemies were homing into the top left corner of the screen and I had no idea why. I tried many things in an attempt to fix this bug. Until I realized something. When I select the tower, and move it with the arrow keys, it updates the coordinates in the console. As I discovered this, my jaw dropped.
The enemy was being fed the wrong coordinates. Instead of the tower's coordinates, it was using [0,0]. This was when I discovered Vector2 which is a 2D vector using floating point coordinates. This means it uses (x,y). So I created a new Vector2 variable and used this instead of getting the coordinates another way. This was the result. (Only the skull was hooked up to the homing system)
It finally works!!! I spent so much time debugging and troubleshooting this, and to have it working is an amazing feeling. Now I need to hook the other three enemy variations up to the homing system.
Waves
Moving onto the next key feature, I felt the next step of development should be waves.
I was able to find another tutorial for enemy waves in 2D With the tutorial, I created the UI as a node in the main scene. I added labels for the current wave and the "Next Wave" text.
It took some time to implement and mess with, but eventually got a crude version working. Though it isn't the prettiest, I can always improve it later.
It was a lot simpler than I thought it would be. The waves are only comprised of two short scripts and the driving code.
In short, the wave_counter function is put into the enemy script. It can be fired either when the enemy is on screen, or off screen. Then, once the threshold of enemies has been spawned/removed, stop the wave and show the "Next Wave" text. Also, the timer variable is what determines the time between spawns. Stopping the timer gives a brief lull between waves.
‹ Previous Devlog: #5 Next Devlog: #7 ›