var ground : GameObject;
var numberOfBuildings : int = 20;
var inititalBuildingNumber : int =20;
var numberOfRows : int = 5;
var building1 : GameObject;
var building2 : GameObject;
var building3 : GameObject;
var MyPosition = Vector3(10, 0, 10);
var buildingType = 4;
var zchange = 10;
var nothing : GameObject;
var rowchange = 0;
var rowchangeIncrease = 10;
function Start (){
inititalBuildingNumber = numberOfBuildings;
var newObj = Instantiate (ground, Vector3(0,-0.1,0), transform.rotation);
newObj.transform.localScale.z = numberOfBuildings*20;
newObj.transform.localScale.x = numberOfRows*40;
}
function Update () {
if (numberOfBuildings > 0) {
buildingType = Random.Range (1,5);
print (buildingType);
switch (buildingType) {
case (1) :
Instantiate (building1, MyPosition, transform.rotation);
MyPosition += Vector3 (0,0,zchange);
numberOfBuildings--;
break;
case (2) :
Instantiate (building2, MyPosition, transform.rotation);
MyPosition += Vector3 (0,0,zchange);
numberOfBuildings--;
break;
case (3) :
Instantiate (building3, MyPosition, transform.rotation);
MyPosition += Vector3 (0,0,zchange);
numberOfBuildings--;
break;
case (4) :
Instantiate (nothing, MyPosition, transform.rotation);
MyPosition += Vector3 (0,0,zchange);
numberOfBuildings--;
break;
}
}
else {
if (numberOfRows > 0){
print ("next");
MyPosition += Vector3 (rowchangeIncrease,0,-(zchange*inititalBuildingNumber));
numberOfBuildings += inititalBuildingNumber;
rowchange += rowchangeIncrease;
numberOfRows--;
}
}
}
I got it to work for me after I fiddled around for a bit and changed and reorganized some of your code