The question is answered, right answer was accepted
Trying to change from fixed to random.
hello, I'm still new to coding and I wanted to change my code here for a building generator from a fixed height/amount of floors to a random amount to give the buildings variety.I attached my code to see it.`enter code here` using UnityEngine; using System.Collections;
public class BuildingGenerator : MonoBehaviour {
 public GameObject[] Groundfloor;
 public GameObject[] Middle;
 public GameObject[] Roof;
 // Use this for initialization
 void Start () {
     int numberOfFloors = 5;
     for (int floor = 0; floor < numberOfFloors; floor++)
     {
         if(floor == 0)
         {
             AddLobby(0, 0, 0);
         }
         else if (floor < numberOfFloors - 1)
         {
             AddFloor(0, floor, 0);
         }
         else
         {
             AddRoof(0, floor, 0);
         }
     }
 
 }
 void AddLobby(float x,  float y, float z)
 {
     if(Groundfloor.Length > 0)
     {
         int index = Random.Range(0, Groundfloor.Length);
         GameObject newGround = Instantiate(Groundfloor[index]) as GameObject;
         newGround.transform.parent = transform;
         newGround.transform.localPosition = new Vector3(x, y, z);
     }
 }
 void AddFloor(float x, float y, float z)
 {
     if (Middle.Length > 0)
     {
         int index = Random.Range(0, Middle.Length);
         GameObject newFloor = Instantiate(Middle[index]) as GameObject;
         newFloor.transform.parent = transform;
         newFloor.transform.localPosition = new Vector3(x, y, z);
     }
 }
 
               void AddRoof(float x, float y, float z) { if (Roof.Length > 0) { int index = Random.Range(0, Roof.Length); GameObject newRoof = Instantiate(Roof[index]) as GameObject; newRoof.transform.parent = transform; newRoof.transform.localPosition = new Vector3(x, y, z); } }
 // Update is called once per frame
 void Update () {
 
 }
 
               }
Follow this Question
Related Questions
Collision check 0 Answers
How can I model a building in Unity using lat, long, alt coordinates? 0 Answers
How can I use the text generator with the UI? 1 Answer
Make an enemy generator 0 Answers