- Home /
Question by
exoticgaming136 · Mar 12, 2012 at 07:58 AM ·
aispawningspawnpointswavesspawning-enemies
ai spawning please help
there something with my ai spawner pretty much this is for waves but im not sure its not working im attached it to a game object and nothings working its saying its all mest up heres the script
#pragma strict
var spawnPionts : Transform[];
var enemyPrefabs : GameObject[];
var yieldTimeMin = 2;
var yieldTimeMax = 5;
static var enemyCounter = 0;
var spawnXOffsetMin = 0;
var spawnXOffsetMax = 0;
var spawnZOffsetMin = 0;
var spawnZOffsetMax = 0;
var spawnYOffsetMin = 0;
var spawnYOffsetMax = 0;
var defaultSpawnNumber = 3;
var waveNumber = 1;
var isSpawning = false;
function SpawnEnemies (wave : int)
{
var spawnNum = (defaultSpawnNumber + 3 * (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 = spawnPionts [Random.Range (0, spawnPionts.length)];
Instantiate (object, Position.position +
Vector3 (Random.Range (spawnXOffsetMin, spawnXOffsetMax), 0,
Random.Range (spawnZOffsetMin, spawnZOffsetMax)), Position.rotation);
enemyCounter++;
}
isSpawing = false;
{
function UpdateWave();
{
waveNumber++;
SpawnEnemies(waveNumber);
}
function Start ()
{
SpawnEnemies(waveNumber);
}
function Update ()
{
if(enemyCounter == 0 && !isSpawing)
{
UpdateWave();
}
}
Comment
Your answer
Follow this Question
Related Questions
Spawn waves & wait till it's killed, spawn again. 1 Answer
Spawn Point 2 Answers
How to increase int every 5 waves? 1 Answer
Spawning help 1 Answer