Hello their Unity developers, I am currently making a T.D/F.P.S like game where waves of enemies come at you and you have to defend yourself from them, I have a code that spawns in the enemies at a place but the problem is that it won’t stop Instantiating it. I know this is because of the code being called in Update() but I want to check the level you are on. Heres my code:
public function SpawnEnemies(enemies : int, spaceBetweenEnemies : float, EnemyForWave : Transform, SpawnPoint : Transform) : int
{
for(var i = 0; i < enemies; i++)
{
/*if(enemies <= enemies) this line does not work, i've also tried if(enemies >= enemies)
{*/
Instantiate(EnemyForWave, SpawnPoint.position, SpawnPoint.rotation);
}
//}
}
function Update()
{
//the problem is here
if(wave == 1)
{
SpawnEnemies(5, 1f, RegAi, spawnArea);
}
}
Please help
Sorry if I maybe wasn’t clear.
Thanks
_1