- Home /
Bind prefab position to GameObject
Hi,
I would like to bind the prefabs position to the gameobject, which is holding it. Right know when I move the gameobject the center of the other prefabs inside the gameobject don't follow it. how can I fix this?
EDIT My case: I am creating a prefab made out of 2 prefabs. Then in the scene when i am moving the gameobject through the inspector, all the parts don't stay together, thoug the visual is still the same and correct.
Thanks in advance,
Cheers
Do you mean you want to instantiate something and then parent it?
Not necessary. I am going to edit the question and detail my case a bit more
Answer by Joshua · May 04, 2011 at 12:58 PM
GameObject.Find("name of the second prefab").transform.parent = GameObject.Find("name of the first prefab").
But easier would be to just make the entire thing a single prefab, and make the prefab inside of it just a child of it in the editor.
Thanks Joshua, I am working in the editor, so no need to use Find... Thanks anyway.
In that case just make it one big prefab, no need for two different prefabs inside a prefab ;)
Your answer
![](https://koobas.hobune.stream/wayback/20220613131417im_/https://answers.unity.com/themes/thub/images/avi.jpg)