Cooldown Systems (Game Dev day 9)

Jack Leavey
2 min readJul 21, 2021


Cooldown systems effect multiple aspects of every game you play. It controls things like Fire rate or attack speed, frequencies of spawning items or entities, and the delay in time between abilities or functions.

Cooldowns effect the rate of fire, as well as the frequency of new enemy spawns.

So how do we set up basic cooldowns? We can utilize multiple variables to create a window of time where an input or function cannot run. In this example, I will be covering the rate of fire of the player.

The “shoot” button allows the player to fire off one of the “Lasers” but without a cooldown system in place it will fire as fast as the player can click. I want to make sure there is at least a 10th of a second delay, which will still allow the player to rapid fire but will cap it from truly egregious fire rates.

The first thing to do is to create our two variables: fireRate and canFire

The two variables we need to create a fire rate system.

You can name these anything you want, so long as your following code matches your variables’ names.

What these two lines are telling the program is:

the player can fire when Time.time + Fire rate is = the canFire value

In our case, Fire Rate is 0.1 and our canFire value is -1, which means so long as we don’t fire off more than 10 “lasers” per second, we can always shoot when we press the space bar.

The second line of code is telling the program to instantiate (or pull from a reference) our laser prefab at the player’s location + a slight offset on the Y axis (to avoid clipping). The Quaternion.identity refers to the rotation of an object, and as we are not concerned with rotation for this function, we just use the .identity to keep the defaults.



Jack Leavey

I am a software engineer with years of experience branching into game development, specifically in Unity. Follow along for guides on creating game mechanics!