Unity Guide

Creating a cooldown system in Unity

A quick guide about how to implement a cooldown system for a space shooter game in Unity

This is the player shooting without a cooldown system.

Creating the cooldown system

First, we need to open the script that controls the behavior of our player:

This way it will take 0.2 seconds to enable the next shot of the player.
_canShoot will store the new second in which the next shot of the player will be enabled.
This will enable the next shot after 0.2 seconds

Understanding the flow

In order to understand the flow between the variables and the execution time of the game we can refer to the next table. Suppose we have the next initial values for the variables:

  • _fireDelay = 0.5f
If we set the _fireDelay like this, the next shot will be enabled after 0.5 seconds.

A passionate computer technology engineer and Unity developer that is always looking to grow in every aspect of life :).