- Home /
Instantiate Prefab in another Prefab
Hi,
I know that there are questions asking something similar already, but I wasn't satisfied with what I managed to find.
Anyway, what I want to know is how do instantiate a prefab as a child of another prefab. I can't just use the GameObject.Find() because I will have multiple instances of the parent prefab. Basically I'm trying to make a staircase generator. The steps are children of an empty game object which is placed using the editor.
I'm scripting in C#.
Thank you for helping me out.
You need to keep track of the potential parents in the logic for your game, normally you would do that by keeping references to the step parents and having the logic use that to pass on the information when they create a new child. Then you set the transform.parent of the child to the transform of the parent.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Dynamic Stairs Generation 0 Answers
My objects instantiate at a strange z coordinate 0 Answers
Multiple Cars not working 1 Answer
Destroying assets is not permitted to avoid data loss. 0 Answers