I have been looking around for this a bit, but havent been able to find anything.
I am trying to instantiate a prefab inside an already existing hieracy in the scene.
Lets say that I want an orderly instantiated city. With old and new houses
I want all the old houoses to be instantiated under the Old Gameobject, and all the new houses to be instantiated under the New Gameobject. Is this possible?
instantiate the objects and then alter their transforms parent property
That's very easy but you have to know that the hierarchy is stored in the transforms (that's what I had been struggling with when I first tried doing this).
So, what you do is
Instantiate your prefab and grab the reference into a variable (e.g. newObject)
Look for the transform of the game object you want to have as parent (e.g. parentObject)
Relevant documentation in the scripting reference: Transform.parent
Hello, i'm trying to do the same thing but with multiple objects being instantiated simultaneously. i can only seem to get the first object to parent through the script... any ideas? Thanks
instantiate the objects and then alter their transforms parent property
– matyicsapoComments are not really meant to post answers. Use comments for asking for clarification of the question, or to comment answers.
– jashan