Cooldown to limit firing our laser.

In the last couple of articles, we set up our player to fire lasers using the Instantiate method, and we also used the Destroy method to remove our lasers when they went off-screen. Now we need to make a cooldown system to limit how fast we can fire the lasers.

We can use Time.time, which tells us how long the game has been running. We can set a fire delay which we will add to the current time. When the current time exceeds the previous Time.time and the delay, we can fire again.