Spawning enemies at set locations at random?

Hello All,

In short, i need to spawn enemies at 9 locations at random always keeping one space free then destroying/killing them once they’ve appeared after a short time then repeat.

Im creating a 2d game so that should make things less complicated i hope. I’ve already tried a few ways but with no luck what so ever, I’ve reached the ‘headbutt wall phase’…

using UnityEngine;
using System.Collections;

public class Spawner : MonoBehaviour
{
	public float spawnTime = 5f;		// The amount of time between each spawn.
	public float spawnDelay = 3f;		// The amount of time before spawning starts.
	public GameObject[] enemies;		// Array of enemy prefabs.

	
	
	void Start ()
	{
		// Start calling the Spawn function repeatedly after a delay .
		InvokeRepeating("Spawn", spawnDelay, spawnTime);
	}
	
	
	void Spawn ()
	{
		// Instantiate a random enemy.
		int enemyIndex = Random.Range(0, enemies.Length);
		Instantiate(enemies[enemyIndex], transform.position, transform.rotation);

	}

}

This is the code that ive tried working around from unity’s example if it helps (excluding all my failed attempts).

Any help would be greatly appreciated!

Thanks,
Max

I use this to make a player spawn at a random spawnpoint… maybe you can rewrite it for that you need

void OnConnectedToServer() {
int Snr = Random.Range(0,31);
Network.Instantiate(playerPrefab, spawnPoints[Snr].transform.position, transform.rotation, 0);
}

public void SpawnP()
{

	GameObject[] go = GameObject.FindGameObjectsWithTag("SpawnPoint");
	
	foreach(GameObject enemy in go)
		spawnPoints.Add(enemy.transform);
}