Navigating the Waves: A Glimpse into My Enemy and Drone Wave Mechanics

Scott Sourile
3 min readOct 24, 2023

--

In the dynamic realm of game development, challenges are as omnipresent as the joys of creation. Recently, while working on an intriguing project, I grappled with one such challenge: orchestrating the rhythmic waves of enemy drones.

The Game Plan

My game features a series of enemy waves, each with distinct characteristics. The objective was straightforward — once a wave of regular enemies concludes, there should be a 12-second interlude before the next wave, comprising of drone enemies, commences. Sounds simple, right?

Tackling the Waves

The logic was built around an Update() method that keeps track of the elapsed time between waves. As the timer hits the 12-second mark, a series of actions get triggered. The spawning of regular enemies should cease, and the drone enemies should start spawning.

Challenges Along the Way

My coding friends had astutely observed that there might be an inconsistency in the spawning logic. On scrutinizing the code, it was evident that the drone enemy spawning Coroutine was starting but then abruptly exiting. The game’s desired behavior wasn’t aligning with the actual outcome. While the timer was resetting at the 12-second interval as intended, the drone wave wasn’t spawning as expected.

The Current Horizon

Thanks to some fruitful discussions and code tweaks, the system’s understanding deepened. The game is now at a stage where:

  • The _betweenWaveTime timer correctly resets after 12 seconds.
  • Flags like _stopEnemySpawning and _stopDroneEnemySpawning are being set to govern the spawning behavior.

Moving Forward with Optimism

Game development is as much about perseverance as it is about creativity. The current situation serves as a testament to the iterative nature of coding — we code, debug, learn, and then code some more. As for next steps:

  1. Rethink the Structure: One potential way forward is to refactor the wave system using an array or list structure, combined with a switch case or a state machine pattern. This would allow for a cleaner organization of waves and easier adjustments in the future.
  2. Debugging and Logging: Introduce Debug.Log() statements in strategic areas to gain better insight into the flow and pinpoint unexpected behaviors.
  3. Community Feedback: Engage with the developer community. A fresh pair of eyes can often spot something that might have been overlooked.

In the grand mosaic of game development, each challenge is but a pixel. The broader picture is about the joy of creation, problem-solving, and the euphoria of watching your vision come to life. Here’s to embracing the waves — both in games and in the journey of development!

--

--