Code used for Firing Lasers

I wanted to know why Random.value< Time.deltatime*shotsPerSecond is used for the enemy laser while InvokeRepeating is used for the player laser?
Shouldn’t InvokeRepeating also work for the enemy laser?
When is a good time to use one projectile fire rate controller versus the other?

Essentially, because you don’t want all enemies firing lasers at the same time

Therefore it’s randomized to spread it out a bit so some fire and some don’t at any given time period.

Whereas for the player, the user is controlling when lasers should be fired, and would expect a constant stream whilst they have fire pressed.

Hope that makes sense

Privacy & Terms