Reasonable Spawning Rule- Game Dev Series 45

Objective: Balance the rules of powerup spawning.

So far we already have 6 powerups(or 7, including poison) randomly spawning during the game. However, we usually get what we do not need at the right time, that is because the spawning system is messy. We simply add the newest powerup in to the old spawning routine.

In this article, we will fix the balance between all the powerups.

The first part is figuring out what should shows up with higher frequency. When the game just began, you might not need the repair powerup since there are less enemies, which I would set the repair to the lowest frequency.
Furthermore, shield and speed powerups are what players want but not so necessary, I would place them to the middle.
With these figuration, we can sorting the tiers.

  • Tier 1- ammo, triple shot.
  • Tier 2- shield, speed.
  • Tier 3- repair

Now we can adjust the SpawnManager.

SpawnManager

For the original spawning coroutine with detecting enemies and triple shot counts, I would set it as tier 1 spawning rule.

Notice that you might need to change the powerup ID and replace the prefab in SpawnManager editor if you change the spawning frequency like mine.

The next is to extract tier 2 and 3 into separate coroutine.
Tier 2 is quite easier, we just need to set a delay at the beginning so it will not mix the spawning into tier 1.

Remember, the waiting seconds should be different with tier 1, with a longer spawning gap time.

With tier 3, we should set some rules on spawning. We will need this powerup when the numbers of enemies is quite a lot. To do this, we can simply use the integer of counts spawned normal enemies to control the spawning frequency.

Then, don’t forget to start these coroutine at StartSpawning().

All done! You can always change the random spawning time to get a well-balanced game experience.

A passionate gamer whose goal is to work in video game development.