Better naming suggestion (spoiler for the challenge)

I went with a similar solution to the first option presented, only I separated it out in that within Shoot() I check if the cooldown is still running and if so I return.
Then I check if the mouse button is set and if so, I make note of the time and fire the bullet.

Now, I can see that always checking the current time with someTime + interval might be an extra calculation every time so it would be sensible to only do the addition once and keep that value…
But then _lastFireTime isn’t quite right anymore, it’s now the lastFireTime plus some offset.

I’d rather call it something like _weaponCooledDownTime instead, now…

Privacy & Terms