Calling an object from a different JS Script and Instantiate it

Hi everyone,
I already have House_1 script in which i built a house with columns. Now i need to build another house (script: House_2) in which i 'll put it a few columns too. Instead of copy-paste the same code to build those columns, i prefer to Instantiate the column object by the previous script. try to avoid the same many code lines as i had with the House_1 script.

Here is the main idea:

Class House_1:

var oColumn = GameObject.CreatePrimitive(PrimitiveType.Cube);
oColumn.transform.position = Vector3(RandX -3.2, 1.7840475, RandZ + 3.3772203);
oColumn.transform.parent = oMainBuilding.transform; //parenting = "Column right 0";
oColumn.transform.localScale.x = 0.05992945;
oColumn.transform.localScale.y = 0.3776168;
oColumn.transform.localScale.z = 0.08529133;

Class House_2 ( i tried 3 options, close to my problem):


`var column : House_1 = GetComponent(House_1);

And got the exception: “‘oColumn’ is not a member of ‘House_1’.”


`var column: GameObject;
column = GameObject.Find("House_1/Column right 0");
column.transform.parent = oMainBuilding.transform; //parenting
column.transform.position = Vector3(RandX, 1.7840475, RandZ + 3.3772203); = "column";
column.transform.localScale.x = 0.05992945;
column.transform.localScale.y = 0.3776168;
column.transform.localScale.z = 0.08529133;`

No exception but i can’t see anything.


`var columnObj : GameObject;
var column= GameObject.FindWithTag("House_1/Column right 0");
columnObj.transform.parent = oMainBuilding.transform; //parenting
Instantiate(columnObj, column.transform.position, column.transform.rotation);`

And got the exception: “UnityException: Tag: House_1/Column right 0 is not defined!
UnityEngine.GameObject.FindWithTag (System.String tag) (at C:/BuildAgent/work/6bc5f79e0a4296d6/Runtime/ExportGenerated/Editor/BaseClass.cs:414)”

Anyone knows why? Or know what i can do to see the column in my new House?
Thanks in advance.

You’re not writing your entire code so it’s hard to say, but apparently oColumn isn’t declared in the correct scope. It should be a member of the class, not a var from the function.