Balancing my powerup spawning system

Michael Kline
Apr 26, 2021

Right now, my powerup spawning system works fine but I want to separate the ammo and health powerups from the rest of the group so I can tweak their spawn rates independently. I’d rather have the health spawn rarely and have the ammo spawn frequently.

I’ll work in the spawn manager script for this one, and I’ll create two new GameObject variables to reference the health and ammo prefabs. From there, I created a new coroutine specifically for health and ammo. At the beginning of the spawn loop, it creates a random number between 1 and 5. If it’s 1, it spawns health. Otherwise, it will spawn ammo. I’m making a call in the StartSpawning method to start this new coroutine so it will run in parallel with the others.

SpawnManager.cs

--

--