Creating A Cooldown System in Unity

in most shoot’em up style games there is some control to the rate of fire. The example above would suit a rapid fire power up but what if we want to control it or slow it down.

to control the rate of fire we will need a variable to recognise it

then we want to check that when the space key is pressed the time passed is greater than a variable which we will call “_canfire”.

this if statement will control both these conditions through “&&” operator which carries out the command if both check conditions are made

when “time.time” is greater than “_canfire” we can the laser

--

--

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