Hello. This is my script I am using to spawn enemies in my game. I want to make it so that enemies will spawn every few seconds until the number of objects with the “Enemy” tag exceeds the number of the “Projectile.Defeat” number exceeds the specified value. I tried adding “Invoke repeating”, and I get no errors, but now no enemies spawn at all, how can I fix my script? Thanks
var objs : GameObject[];
var gos : GameObject[];
gos = GameObject.FindGameObjectsWithTag("Enemy");
InvokeRepeating("LaunchProjectile", 2, 0.3);
function LaunchProjectile () {
if (Projectile.Defeat < 30)
{yield WaitForSeconds(2.0);
for (var a = 0; a < 3; a++)
Instantiate(objs[(Random.Range(0, 3))], new Vector3(Random.Range(481.5735, 559.3441), -791.811, Random.Range(380.1254, 420.0663)), Quaternion.identity);
if(gos.length > 20)
{
}
}
}