Good afternoon, I have a for loop I am using to spawn my enemies. I have set the positions to 4 Vector3 random ranges stored in an array so the enemies spawn outside of the Game View. My enemies are randomly spawning as I have defined, however they spawn at the same 4 random locations until the level restarts. I would like every iteration of the loop to spawn the enemies in a different location. Could someone please provide some insight as to why it is working in this fashion and how I could change it?
var spawnValuesL : Vector3;
var spawnValuesT : Vector3;
var spawnValuesR : Vector3;
var spawnValuesB : Vector3;
function SpawnWaves () {
var spawnPositions : Array = [Vector3(spawnValuesL.x, spawnValuesL.y, Random.Range (spawnValuesL.z, -spawnValuesL.z)),
Vector3(Random.Range (spawnValuesT.x, -spawnValuesT.x), spawnValuesT.y, -spawnValuesT.z),
Vector3(-spawnValuesR.x, spawnValuesR.y, Random.Range (-spawnValuesR.z, spawnValuesR.z)),
Vector3(Random.Range (spawnValuesB.x, -spawnValuesB.x), spawnValuesB.y, spawnValuesB.z)];
var spawnRotation : Quaternion = Quaternion.identity;
yield WaitForSeconds (startWait);
for(var i : int = 0; i < hazardCount; i++)
{
if(!pooledObjects*.activeInHierarchy)*
-
{*
_ pooledObjects*.transform.position = spawnPositions[Random.Range(0,4)];_
_ pooledObjects.transform.rotation = Quaternion.identity;
pooledObjects.SetActive(true);*_
* }*
yield WaitForSeconds (spawnWait);
}
}