Hi, so I have to have zombies spawn at one of four spawners. My problem is that I don’t know how to put in more than one location as the spawn locations. I tried doing
Instantiate(Zombie, (spawn1 || spawn2 || spawn3 || spawn4), etc...)
but that did not work. Is there any other way I can do this?
1 Answer
1
This is quite simple just make an array which contains your possible spawn locations and pick one randomly. The code could look like this (c#):
public Transform[] spawnPoints; //assign the spawnpoints in the inspector or during Start
void SpawnZombie(){
int pick = Random.Range(0, spawnpoints.Length); //select one spawnpoint randomly
Instantiate (Zombie, spawnPoints[pick].position, spawnPoints[pick].rotation);
}
I like how you think, but unfortunately OR works with boolean arguments and thus are those spawnpoints converted to true/false.
– Unitraxx