Essentially my game is a game where enemies have spawn points based on a Transform list. Well you have multiple paths you can take, so my old way of just replacing the list with every door no longer works. Is there a way I can add Transforms to this current list ? Example would be
Script 1
public Transform spawnPoints;
public float SpawnTime;
public GameObject Enemy;
void Start(){
InvokeRepeating ("Spawn", SpawnTime, SpawnTime);
}
void Spawn ()
{
int spawnPointIndex = Random.Range (0, spawnPoints.Length);
Instantiate (enemy, spawnPoints [spawnPointIndex].position, spawnPoints [spawnPointIndex].rotation);
}
and Script 2 would have to work in a way that I can add to the list SpawnPoints. It’s not as simple as
public Transform[] AddPoints;
public void AddSpawnPoints(){
SpawnPoints+=AddPoints;
}
I tried it in hopes , even tho I knew it wouldn’t. So any help ?
Try a list instead:
List<Transform> SpawnPoints;
SpawnPoints.AddRange( AddPoints );