- Home /
how to disactive or destroy the children
i wont to destroy or disactive a GameOpject(Monster) and his childs(weapons) , i tried Disactive but it just DisActive the Monster without the chilrden
Comment
Best Answer
Answer by Kourosh · Apr 13, 2011 at 02:52 PM
To Deactivate:
GameObject.Find("Monster").SetActiveRecursively(false);
Answer by tyson · Apr 13, 2011 at 01:40 PM
chidren = GetComponentsInChildren(Transform);
for (var child in children)
{
Destroy(child.gameObject);
}
Answer by robertmathew · Apr 13, 2011 at 01:36 PM
var onoff : boolean; var testObject : GameObject;
function Update () { if (onoff == true) testObject.active = true;
if (onoff == false) testObject.active = false; }