T . Kathiravan
2 min readApr 21, 2021

Cool Down system in Unity

When a player fires a laser using any keys , there is a continuous stream of bullets as we see below.

Without Cool down

It gives advantage to the player so the user experience with the attack will be low. So to increase user experience and to create enemies of
equal strength , we create a cool down system in games where the user cannot fire continuously and some time intervals will be given between the keypresses to enhance
user experience.

Instantiation Script

Laser Script

Let us create a cool down system

Cool Down System

Lets us create a variable _fireRate=0.5f and _canFire=0.0f

for every half second I want to fire a bullet , so my _fireRate is 0.5f , you can change the values according to your need.
so when can I fire ,what is condition for firing ? In the first case let assume _canFire=0.0f

so when the space key is pressed and Time.time > _canFire , at this time let say Time.time is 1 second

Iteration

so now you can test ..though you have urge to fire a bullet , you have to wait for your time and this user experience is enhanced.

No responses yet