Generic cooldown method
My game has a lot of cooldowns for different functionality. They are all executed in identical coroutines like this:
IEnumerator ShootCooldown()
{
canShoot = false;
yield return new WaitForSeconds(shotDelay);
canShoot = true;
}
What I'd like to do is create a generic cooldown method into which I can pass a cooldown time and a reference to a boolean variable to toggle. The issue is that I can't do this with my current setup because iterator methods can't take reference parameters. I've also looked at Invoke() but that would still require me to still have a separate method for every cooldown.
Is there any way to create a generic cooldown method like this? Or maybe a better way of going about it that I'm not aware of?
Your answer
![](https://koobas.hobune.stream/wayback/20220612160817im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
C# cool down not looping 0 Answers
How to have a speed Boost in my game? 2 Answers
Weapon Fire Rate does not change intervals between each bullet C# 0 Answers
Character Controller rotation not working. 0 Answers
Screenshot on Android 2 Answers