Hello, I am trying to use this script to spawn the enemies in my game (over a set interval of time using a random number, so that once every 15 seconds anywhere between 3 and 8 enemies will be instantiated)but it wont work, what is wrong? Thanks
public Transform[] ObjectsToSpawn;
public float SpawnInterval= 15;
public float MaxObjectsSpawned = 8;
public float MinObjectsSpawned = 3;
private float _NextSpawn
void Start() { _NextSpawn = Time.time + SpawnInterval;}
void Update()
{
if(Time.time >= _NextSpawn)
{
int objectsToSpawn = Random.Range(MinObjectsSpawned, MaxObjectsSpawned);
for(int i < 0; i < objectsToSpawn; ++i)
{
Instantiate(ObjectsToSpawn(Random.Range(0, ObjectsToSpawn.Length), transform.position. Quaternion.identity);
}
_NextSpawn = Time.time + SpawnInterval;
}
}