- Home /
Disable GameObject Only Father Not Children
I am using Unity 4 Or a GameObject with a hierarchy Father and son I would like to disable only the Father and Son Get Active I know this in Unity 3 is possible but not unity 4 there must be another method to achieve this also in unity 4 Can someone help me Thanks
From where do you want to do it? Dont know any way to do it but not disabling the parents, but ins$$anonymous$$d deactivate componets on them, but leave transforms intact.
Is your hiarchy:
Father (want to disable)
Father->Son (want to disable)
Father->Son->Child (dont disable)
Father->Son->Child (dont disable)
Anytime I'v ever Disabled a Parenting object, the child objects get disabled to
Turn off the renderer or other "visible" components for the father object. Turning off the father gameobject will disable all children as well
Answer by tanoshimi · Nov 06, 2014 at 07:04 AM
As far as I know, what you're asking is impossible. From the Unity 4 release notes, "GameObjects active state will now affect child GameObjects, so setting a GameObject to inactive will now turn the entire sub-hierarchy inactive".
Child gameobjects' behaviour is defined, in part, by the behaviour of their parents, so it doesn't really make sense to have an enabled child of a disabled parent object.
I had already tried many solutions the problem ' I want to make an animated scene in the game when the player enters the trigger scene is activated so everything is ok but the problem 'this, the player continues to move during the scene, its input, controller, working at the scene and that's not good, the player must remain motionless during the scene must not move or tried several solutions, including: Disable the father by: GameObject.SetActive = false but this also disables the children including and including the $$anonymous$$esh 'Player not visible pause the game, with timescales etc .. But this blocks all The entire game, including the scene make invisible meshes etc. the only method that works a bit rudimentary and 'what disable caracter controller, input controller and all the other scripts that generate the movement of the player Script the GetComponent ......through one by one Script in the Player
At this point I'll have another question If you need to make an animated sequence in your game how do you prevent you from moving to the player?
See the answer above. You'll need to come up with a different way to organize your object hierarchies, or an approach which does not require the functionality you're seeking.
Answer by toddisarockstar · Nov 16, 2014 at 11:40 PM
create an empty game object in the unity Gameobject dropdown menu at the top. drop both your objects into it so both "real" objects can be treated as seperate children. the empty object still holds em together as a parent.