What I can’t figure out is how to: Make a parent, with some children in javascript.
I am creating a simple game where the player creates a shape out of some boxes. The next level instantiates the boxes is the shape the player created. Then the player will then move the object they created, all the boxes are connected together and move as unit. One of the boxes is the main controller and the other boxes are armor. The armor will be destroyed when it is hit.
I have found the combine children scritpt on the forms, however I do not think that would work in my case, since I don’t want to combine the meshes. I have tried, it is little to complex for me to figure out. ![]()
I am creating the boxes by:
var cbox : Transform; // Controller box. I want this to be the parent.
var abox1 : Transform; //1 armor box. This will be a child.
function Start () {
Instantiate(cbox, Vector3 (500, 11, 500), Quaternion.identity);
Instantiate(abox1, Vector3 (500, 10, 500), Quaternion.identity);
}
I am really new to this programing and think that I am overlooking something super simple. :?
I have tried just about everything I could think to try with the Transform.parent and just can’t get it to work. I have used the unity manual and search the forums.
What I can’t figure out is how to: Make the cbox the parent, with the instantiate boxes as the child
In unity it is a simple drag an drop to make it a child.
I just can’t find out how to do it in javascript. :?
Maybe I am going about this in the wrong way, is there any other way to attach the boxes together.
Thanks,
Confused