I have this script, that deactivates the weapon of the player at star. But it deactivates only the parent object, and not all the other children, so, some parts of the weapon are visible. Any help/example?
var weapon : GameObject;
var holdingaxe : boolean = false;
function Start ()
{
weapon.active = false;
}
function Update ()
{
if(holdingaxe)
{
weapon.active = true;
}
}
as the one above me wrote
weapon.SetActiveRecursively(false)
http://docs.unity3d.com/Documentation/ScriptReference/GameObject.SetActiveRecursively.html
or
function Start ()
{
SetActiveRecrusive(weapon,false);
}
public function SetActiveRecrusive(TheChild : GameObject , State :boolean)
{
thechild.active=state;
foreach (Transform child in transform)
{
SetActiveRecrusive(child ,State );
}
}
this will go over all the subchilds and you can do what ever you want
sfc