- Home /
How can I activate an empty object which is parent of child objects?
Hi mates!.
I'd like to know how to activate an empty GameObject (called WOW) which is parent of 3 child objects. I want my parent object is activated only when a counter (called counter) reaches some value (3 for instance). counter is incremented in other script and was defined as a global variable. Te code es more or less the next:
private var counter:int;
private var WOW :GameObject;
function Start ()
{
WOW.active = false; //I want initially my object deactivated
}
function Update ()
{
if (counter==3)
{
WOW.active = true;
}
Thanks in advance.
Answer by timsk · Sep 30, 2011 at 12:43 PM
http://answers.unity3d.com/questions/10733/enabledisable-objects-with-script.html
If you read the answers in that thread you should be ok. Theres nothing wrong with your code.
In case your super lazy 8). Basically, once you do .active = false on a gameobject, its no longer active, therefore any scripts attached to it wont be executing Update().
Just attach this code to another gameobject, and use GameObject.Find to find WOW.
Thanks for your answer. Finally I'm trying instantiating ins$$anonymous$$d of activating...