InvokeRepeating for enemy ships

Why are we not using InvokeRepeating for enemy ships ? Do they use more resources ? If using InvokeRepeating, I call the method in start(), so can I change the repeat rate after that or does it stay the same ?

Hi Naumaan,

Could you be a little more specific, your question is without context so hard to understand? Perhaps with an example of the code?

InvokeRepeating for enemy ships to fire like we used for player.

void Start(){
		InvokeRepeating ("Fire", 1f, fireRate);
		}
	void Fire(){
		Instantiate (shipLaser, transform.position, Quaternion.identity);
	}

Hi,

Ah I see, for firing. Well you could, but, the approach taken for the player was to prevent a solid stream of projectiles if the player just held down the fire button. You don’t have the keyboard input to worry about with the enemies but you do want to add a degree of randomness to make the game feel more realistic.

If you use InvokeRepeating you’ll lose that to a degree.

Give it a try so you can see the difference :slight_smile:


See also;

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms