Three ways to cooldown

When making a game in Unity, or any other engine for that matter, there's a good chance you'll need a way to force the player to wait for a cooldown, whether for balancing reason or to stop… shenanigans.

I have found three different ways of doing this:

1: Counting down

Using Time.deltaTime to subtract the duration of each frame from the cooldown remaining.

2: Coroutine

Setting a coroutine to wait for the cooldown and then setting _coolDownReady back to true.

3. Time.time

Time.time holds the total amount of time the program has been running in seconds. Using Time.time to compare against when the next shot is allowed to be fired, and adding the cooldown to the current time after firing a shot.