Description: I want to make a building by script. THe building has its parts as a flat, a parvis, a ground floor, a second floor etc. In the script below i made functions for each part of the building. Then in the main function start() i create these parts and next i try to combine them under their ‘father object’ flat.
Here’s the script:
class IonianHouse{
//create the shapes of IonianHouse building parts
var oParvis = GameObject.CreatePrimitive(PrimitiveType.Cube);
var oFlat = GameObject.CreatePrimitive(PrimitiveType.Cube);
var oGroundFloor = GameObject.CreatePrimitive(PrimitiveType.Cube);
var oFirstFloor = GameObject.CreatePrimitive(PrimitiveType.Cube);
var oLeftCube = GameObject.CreatePrimitive(PrimitiveType.Cube);
var oRightCube = GameObject.CreatePrimitive(PrimitiveType.Cube);
var oFirstFloorRoof = GameObject.CreatePrimitive(PrimitiveType.Cube);
var oColumn = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
var rot: Quaternion = Quaternion.identity;
function Collumns(){
var cloneColumn = Instantiate(oColumn , Vector3(-79.01502,3.930318,10.8331), rot);
//Choose a Structure, which is more capable for the collumn objects
var aColumns : GameObject[3];
oColumn.transform.localScale.x =0.6616377; //X scale of the collumn
oColumn.transform.localScale.y =3.189006; //Y scale of the collumn
oColumn.transform.localScale.z = 0.9843928; //Z scale of the collumn
//Set the Collumns
for(var i =0; i<=aColumns.length; i++){
//puts in the Array the oColumn object clones
aColumns *= cloneColumn;*
-
cloneColumn.Vector3.x += -2; // puts every oColumn object clone near to the next one, X point distance of every clone is -2*
-
}*
-
}*
-
function GroundFloor(){*
-
var pos = oGroundFloor.transform.position;*
-
pos = Vector3(-82.50504,3.930318,30.67108);*
-
oGroundFloor.transform.localScale.x = 14.22;*
-
oGroundFloor.transform.localScale.y = 6.35;*
-
oGroundFloor.transform.localScale.z = 32.66;*
-
Instantiate(oGroundFloor, pos, rot);*
-
}*
-
function FirstFloor(){*
-
var pos = oFirstFloor.transform.position;*
-
pos = Vector3(-82.50504,9.904648,27.14175);*
-
oFirstFloor.transform.localScale.x = 14.22;*
-
oFirstFloor.transform.localScale.y = 5.53;*
-
oFirstFloor.transform.localScale.z = 18.01;*
-
Instantiate(oFirstFloor, pos, rot);*
-
}*
-
function Flat(){*
-
var pos = oFlat.transform.position;*
-
pos = Vector3(-82.49211,0.4076467,27.69778);*
-
oFlat.transform.localScale.x = 14.22;*
-
oFlat.transform.localScale.y = 0.78;*
-
oFlat.transform.localScale.z = 38.55168;*
-
Instantiate(oFlat, pos, rot);*
-
}*
-
function LeftCube(){*
-
var pos = oLeftCube.transform.position;*
-
pos = Vector3(-77.17271,3.258567,12.60766);*
-
oLeftCube.transform.localScale.x = 3.62;*
-
oLeftCube.transform.localScale.y = 4.97;*
-
oLeftCube.transform.localScale.z = 3.61;*
-
Instantiate(oLeftCube, pos, rot);*
-
}*
-
function RightCube(){*
-
var pos = oRightCube.transform.position;*
-
pos = Vector3(-87.83255,3.258567,12.60766);*
-
oRightCube.transform.localScale.x = 3.62;*
-
oRightCube.transform.localScale.y = 4.97;*
-
oRightCube.transform.localScale.z = 3.61;*
-
Instantiate(oRightCube, pos, rot);*
-
}*
-
function Parvis(){*
-
var pos = oParvis.transform.position;*
-
pos = Vector3(-87.12512,-0.006041527,51.18095);*
-
oParvis.transform.localScale.x = 20.05;*
-
oParvis.transform.localScale.y = 0;*
-
oParvis.transform.localScale.z = 15.84;*
-
oParvis.transform.rotation.y = 36.25169;*
-
Instantiate(oParvis, pos, rot);*
-
}*
-
function Start () {*
-
Parvis();*
-
Flat();*
-
GroundFloor();*
-
FirstFloor();*
-
RightCube();*
-
LeftCube();*
-
Collumns();*
-
if (oFlat != null){*
-
//conect the objects: parent-children*
-
oFlat.transform.parent = GameObject.Find("oGroundFloor").transform;*
-
oFlat.transform.parent = GameObject.Find("oParvis").transform;*
-
oFlat.transform.parent = GameObject.Find("oRightCube").transform;*
-
oFlat.transform.parent = GameObject.Find("oLeftCube").transform;*
-
oFlat.transform.parent = GameObject.Find("oFirstFloor").transform;*
-
oFlat.transform.parent = GameObject.Find("oColumn").transform;*
-
}*
-
} } *
Is there something wrong with the code according to what i want to do?
Thanks in advance.