Western Shooter Devblog #12 | Determining How Long Our Speed Powerup Should Last

Just like our shotgun powerup, let’s go ahead and create our speed boost prefab first.

Looking good! Since we made our Powerup Script modular we can just plug in the same script and we won’t need to change anything.

Next we need to apply this new speed powerup prefab to our Spawn Manager. I reworked our Spawn Manager script to allow us to add more and more powerups while still using the same Coroutine!

So no matter how many more powerups we create we can just add a new else if statement with a new number to Instantiate while keeping all the same Cooldown and Spawn Rate settings, and only spawning one powerup at a time!

Now we have our Speed Powerups spawning! Let’s get to coding what we want to happen when the player collects one!

Just like before, it all begins in the OnTriggerEnter() method.

But this time, I decided our powerup will run out on a timer, so we’re going to call a Coroutine method that will have our speed boost behavior.

This is a quick and dirty way to change our speed variables for both movement and fire rate, and then change them back after the cooldown!

We can just adjust these variables in the inspector and we’re done! The player can now move and shoot faster with this powerup for about 10 seconds and then it will run out!

In the next devblog, we’re gonna finish up our powerups by adding a Shields powerup, and learn how we’ll use switch statements to make that happen!