How long should our Powerups last?

Picking up our Shield Powerup.

We should decide how long we should have our Powerups last once the player has picked them up. This can vary depending on which powerup is picked up and how much of a boost you want to give to the player when they pick up the powerup. Currently, I have the Triple Shot and the Speed powerups set to 6 seconds each. You can see that this is hard-coded in the screenshot below in their respective power-down methods.

Activation and power-down methods for Triple Shot and Speed powerups.

We will create a variable for both the Triple Shot and the Speed to determine how long we want them to last, then put those in place of the hard-coded times. We will also Serialize both so that we can modify them in the Inspector.

We set these to 6.0 seconds by default but we can still adjust them in the inspector.

Now we plug the variables back into our code for the respective powerup cool-downs, and we’re ready to go.

Powerup activation and cooldown with new variables used.

Now we have an easy way to adjust the duration of our powerups. Hopefully, you found this informative and at least a little helpful. And in case you are wondering, I didn’t forget about our Shields powerup. I have something in mind for that as well. I’ll probably do an extra article to cover modifying our Shields. Until next time I wish you great luck and success on your coding journey.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store