- Home /
How do I deactivate children With Parents?
Hello. I am making a scene to test a movement for mannequins in my horror game. You walk into a trigger and a group of mannequins are deleted and another group are turned "True" to make an illusion that they moved. The problem is that my script only deactivates the parent empty objects and not the children models. Please help.
#pragma strict
var MannequinGroup1 : GameObject;
var MannequinGroup2 : GameObject;
function Start(){
MannequinGroup1.active = true;
MannequinGroup2.active = false;
}
function OnTriggerEnter(){
Destroy(MannequinGroup1);
MannequinGroup2.active = true;
}
Answer by perchik · Jul 31, 2013 at 07:09 PM
Try SetActiveRecursively(true)
. I know that got deprecated in 4.x, so perhaps it works in 3.x
Apparently, active state was one of the bigger changes between 3.x and 4.x
Answer by jacobschellenberg · Jul 31, 2013 at 05:38 PM
You want to use the .SetActive()
method.
MannequinGroup2.SetActive(false);
Hope this helps :)
Sadly it did not work. I recieved an error message. Assets/HorrorScripts/$$anonymous$$annequinHorror.js(6,25): BCE0019: 'SetActive' is not a member of 'UnityEngine.GameObject'. Did you mean 'active'?
Are you in Unity 3.x or 4.x? SetActive is a member of GameObject
I know SetActive works in 4.x, but I'm surprised it doesn't in 3.x