I am making 3d endless runner and right now my code generates random floor prefabs(I have 6 of them) from the array at the certain time. But instead of random I want specific prefabs to be generated so the player will be passing through different zones. To be more exact - each prefab from the array should be instantiated 3 times in a row and then the next one and so on. When the loop goes through all the prefabs from the array, it should start again
from the 1st prefab.
The code I have now:
public GameObject[] prefabArray;
public float spawnTime;
void Start () {
Spawn ();
}
void Spawn () {
Instantiate (prefabArray [Random.Range (0,prefabArray.GetLength(0))], transform.position, Quaternion.identity);
Invoke ("Spawn", spawnTime);
}