- Home /
Is "null" the best way to unparent a child?
I'm trying to separate a child object created with a spawning system from the parent obect, but currently I am just using "transform.parent = null". However, I've noticed the child itself seems to be vanishing when the parent is destroyed as well, and have ruled out clauses in the child's code. This should not happen when conditions are met. According to documentation - and other questions close to this, null SEEMS to be the best way, but something is going wrong.
if (!follow) {
transform.parent = null;
follow = true;
}
Answer by robertbu · Feb 18, 2013 at 06:30 AM
The code above should do the job. I believe something more is going on. Did you verify that the child object has disappeared from the hierarchy? You could also add an OnDestory() method to both object to check (and output) their parent and child status as they are being destoryed.