Determining how long Powerups last

Simon Leen
Jun 3, 2021

Objective: Create a cooldown system for the powerup.

Since we have already covered cooldown systems previously using IEnumerators(Coroutines), this should be very easy to implement.

Open the player script and create an IEnumerator called triple shot power down and set the yield return to 5 seconds and then set is triple shot active to false. Make sure to put the waitforseconds call before setting the triple shot active to false or else it will call it immediately.

Setting a time limit on the powerup

Then start the coroutine in the triple shot activate method, after setting the is triple shot active to true.

Powerup activates then de-activates after 5 seconds

Now that we have a working powerup and it turns off after the specified time, in the next post, we will move on to creating a speed powerup and making the powerups modular.

--

--