- Home /
Retain references to child gameobjects while duplicating objects
Hello,
Let me explain the scenario in simple words. I have a Parent GameObject with a script on it that spawns a child under that object at runtime. Reference to that child is now saved in a serialized variable on the parent script. Now, when I duplicate the parent object using Instantiate method, that duplicate object also has a similar child since the hierarchy is duplicated too. But the script on the duplicate object does not have the reference to the duplicate child.
It makes sense why this happens. But is there a straight forward way to duplicate an object and its hierarchy and still reference the newly created objects? Or does it just need to be re-referenced on Awake or Start in the script?
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How can I spawn gameObjects within a circle radius? 1 Answer
How can I change a float value of an instantiated object from another script? 3 Answers
My prefab isn't getting destroyed 1 Answer
Problem with a Unity Scripting example from the scripting manual! 0 Answers