- Home /
Deactivated parent with active child
Just watched the tutorial on activating game objects and I came up with a question:
On what situation would I want to set a parent deactivated while keeping one or more of his child(ren) active?
Answer by SohailBukhari · Sep 03, 2017 at 08:58 AM
The unity gameObjects work with the child parent relationship if you deactivate parent gameObject the child will also deactivate.
When a parent object is deactivated, the deactivation also overrides the activeSelf setting on all its child objects, so the whole hierarchy from the parent down is made inactive. Note that this does not change the value of the activeSelf property on the child objects, so they will return to their original state once the parent is reactivated.
Can you give me an example of when I would want to use it?
Let suppose we want to kill enemy and we can deactivate his parent on fire, so all of its children will also deactivate and we can instantiate Ragdoll on his position. Second Scenario is that we want to activate one of its child for example which has blood splatters we just do gameObject.Getchild(0).SetActive(true);
Your answer
Follow this Question
Related Questions
Make a simple tree 1 Answer
Can a parent SetActive a child GameObject anymore 2 Answers
Finding child problems.. 1 Answer
Clone wants a Parent (c#)? 1 Answer