I have a spawn script that so far only creates one Enemy spawn point and enemy trigger while only spawning one enemy.
Instead, I want it to create multiple spawns and triggers, but keep it such that only one enemy spawns at a time, at a random on of the spawn points.
How can I do this?
Here's the relevant code at the moment:
public class SpawnManager : MonoBehaviour {
public GameObject Enemy; // the enemy prefab
public float mytimer; // the time to wait before spawn
private GameObject _spawndEnemy; // the enemy that was spawnd
void SpawnEnemy()
{
var enemySpawnPoint = GameObject.Find("FFEnemySpawn1").transform;
_spawndEnemy = Instantiate(Enemy, enemySpawnPoint.position, enemySpawnPoint.rotation) as GameObject;
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.name == "FFMirror1") {
mytimer = Random.Range(0,15);
Destroy(_spawndEnemy);
Invoke("SpawnEnemy", mytimer);
Debug.Log("Spawn Normal");
}
}
}