How can i instantiate a game object into others GameObject?
What do you mean?
example i has one game object with 4 cubes i want put more cubes intro this gameobject
its possible do this!
?
do you mean parented? one GameObject cannot be more than one GameObject, that doesn’t make sense. You can parent GameObjects to each other though (or more accurately, parent their transforms). That’s what happens when you drag them on top of each other in the scene pane.
Once you instantiate your GameObject just set the parent:
var instantiatedObject : GameObject = Instantiate(myPrefab, pos, rot);
instantiatedObject.transform.parent = parentObject.transform;
i will try
Yep thats how you do it. most likely you’ll want to immediately after setting the parent you’ll want to set stuff like
transform.localPosition = Vector3.zero;
transform.localRotation = Quaternion.identity;
transform.localScale = Vector3.one;
unless when you instantiate with pos and rot you already set it to use a position you want. but keep in mind if your using scaling througout your project you’ll still want to set localscale manually.