How long should our Powerups last?
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.
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.
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.