I am new to scripting.I was trying to make the enemies spawn when a dead enemy counter
drops to 0.
But at line 10 it says
“expecting ),found’+='.(BCE0044)” and
“Unexpected token: 1. (BCE0043)”
At line 12 it says “expecting :, found ‘-=’. (BCE0044)”
Here is the code.
Can anyone help me?thanks.
var enemyCounter : int = GameObject.FindGameObjectsWithTag("Enemy").Length;
var DeadEnemies : int = GameObject.FindGameObjectsWithTag("Dead").Length;
var defaultSpawnNumber = 10;
var waveNumber = 1;
var isSpawning = false;
function RemoveDeadZombies()
{
if (DeadEnemies +=1)
{
enemyCounter -=1;
}
}
function SpawnEnemies(wave : int)
{
var spawnNum = (defaultSpawnNumber + 10 * (wave - 1));
isSpawning = true;
for(var i = 0; i < spawnNum;i++)
{
yield WaitForSeconds(Random.Range(yieldTimeMin, yieldTimeMax));
var object : GameObject = enemyPrefabs[Random.Range(0, enemyPrefabs.Length)];
var position : Transform = spawnPoints[Random.Range(0, spawnPoints.Length)];
Instantiate(object, position.position +
Vector3(Random.Range(spawnXOffsetMin, spawnXOffsetMax), 0,
Random.Range(spawnZOffsetMin, spawnZOffsetMax)), position.rotation);
enemyCounter++;
}
isSpawning = false;
}
function UpdateWave()
{
waveNumber++;
SpawnEnemies(waveNumber);
}
function Start ()
{
SpawnEnemies(waveNumber);
}
function Update ()
{
if(enemyCounter == 0 && isSpawning == false)
{
UpdateWave();
}
}