My problem is that I want my obstacle spawner, which is at a set distance in front of the player's spaceship, to randomly select from a set of different obstacle prefabs each time it instantiates an obstacle. I've found plenty of threads on how to randomize position, but that's not what I'm looking for. I've seen a lot of references to lists and tags but I can't seem to figure out how to implement them correctly. I'll post my spawner script below with comments where I "think" changes are supposed to be made.
using UnityEngine;
using System.Collections;
public class RandomSpawner : MonoBehaviour
{
public GameObject[] spawnObject; //somehow change this to incorporate multiple gameobject prefabs, will an array support that?
//Would I create public variables for each prefab I want to be randomly chosen from, or would those be contained in the array above?
public float xRange = 1.0f;
public float yRange = 1.0f;
public float minSpawnTime = 1.0f;
public float maxSpawnTime = 10.0f;
void Start()
{
Invoke("SpawnWall", Random.Range(minSpawnTime,maxSpawnTime));
}
void SpawnWall()
{
float xOffset = Random.Range(-xRange, xRange);
float yOffset = Random.Range(-yRange, yRange);
int spawnObjectIndex = Random.Range(0,spawnObject.Length);
//above line will have to change to reflect whatever goes above Start, possibly below as well