How To Create A Cooldown System In Unity

A cooldown system is in essence, a timer. You are asking the system to freeze the ability for something to happen for (x) amount of time and then reinstating that ability.

Adam Reed
2 min readMar 28, 2021

To do something like that you could do a few things. One option is to use the “IEnumerator” coroutine and the “WaitForSeconds” function to allow for a set delay in which it will then wait for a certain amount of time before continuing on.

This can get expensive memory-wise if used too much though, so at times where it can be avoided, it is often better to go down a different route.

Another option is to use “Time.time” along with a couple of float values to create a measurement of time as it passes in relation to an action. Time.time is a measurement of how long the game has been running in seconds.

If you look at the code example below, you’ll see this logic used to create a time delay to control a player’s attack speed!

--

--

Adam Reed

Hi, my name is Adam Reed and I am a software engineer specializing in Unity and C# development. Feel free to scroll through and check out some of my work!