Getting down with picking up power-ups

Michael Kline
Mar 27, 2021

Last time, I created the powerup functionality for the player but that’s worthless if I don’t actually have a powerup spawning on the map to be picked up. I’ll add another coroutine to the SpawnManager script to instantiate a new instance of a collectible powerup and wait for a random time between 3 and 7 seconds. I might increase this time later, as it seems like powerups are spawning too frequently.

SpawnManager.cs

The logic already exists for the player to pickup the powerup, but I only want the player to have triple-shot for a few seconds at a time. You know what that means: Another coroutine! This one is in the player script.

Player.cs

EnableTripleShot() is being called from the Powerup script when the player collides with the powerup. Here it is in action.

--

--