Activating/ deactivating object issue ...

Hi
Below is a script that I have to activate and deactive objects when Globals.PlayLevel is set (0 = inactive, 1= active). For some reason the objects list in the deactivation part of the script but not in the activation part. I’m at a loss as it’s the same code, but one of them isn’t listing the objects and the other is. If some one can help me that would be excellent :slight_smile:

thanks
Immy

function Update () {

// what happens when the level is deactivated //

if (Globals.PlayLevel==0)
{
for(var go : GameObject in GameObject.FindGameObjectsWithTag(“ForestLevelObjects”))
{
go.active = false;
print (go);
}

}

// what happens when the level is activated //

if (Globals.PlayLevel==1)

{
Globals.PlayLevel=999;

for(var goo : GameObject in GameObject.FindGameObjectsWithTag(“ForestLevelObjects”))
{
go.active = true;
print (goo);
}

}

}

FindGameObjectsWithTag is documented to return only active objects. So, you’ll have to come up with another way of locating your objects.

Oh . Thanks for the reply, saved me scratching my head all night :slight_smile:

Immy