It wouldn't be fair or realistic if you could just fire your laser as fast as you can hit the space. we want to slow down the rate the laser can be fire. In unity, there is more than one way to accomplish this. I will show you a very simple way this can be accomplished
First, unity gives a way to track the time our game has been running. That is with the command Time. time.
Next, we will need some variables to store the rate we want the laser to fire and a variable to store the time we can fire the laser again. The fire rate is the time between shots and the can fire will be updated with the time we can fire again
Last we need to add these to the fire laser method of our player script. First, we add a check of Time. time against our can fire variable to the if statement of our fire laser method. Notice we use the double ampersand, what this does is only checks the second condition if the first condition is true. This is the most efficient way as it saves on the number of calls. Second, once both conditions are true we will fire the laser and then update can fire with the time of the game plus our fire rate.
There you go a very simple cooldown system for your player.