Activating and DIsactivating

private var isCurrent : boolean = false;
private var isActive : boolean = false;
var weaponNumber : int = 0;


function Update () {
	if(transform.parent.GetComponent(CamControl_SP).current_weapon == weaponNumber)
	{
		isCurrent = true;
	}
	else
	{
	
		isCurrent = false;
	}
	
	
	if(isCurrent == true  isActive == false)
	{
		Arm();
		gameObject.SetActiveRecursively(true);
	}
	else if(isCurrent == false  isActive == true)
		{
			 isActive = false;
			 gameObject.SetActiveRecursively(false);
		}
	}



function Arm () {
isActive = true;
animation.Play ("arm");
}

I’m trying to get my weapons to appear when they are selected and disappear if they are not. The above code works, but only once, than my weapons disappear permanently. Why is this happening?

Once you deactivate an object it stops getting Update() events, so the script won’t ever get called again.

Turn the weapon’s renderer off (enabled = false) instead OR have some external script tell the weapon to activate.

(In general, it’s good to avoid sticking Update() handlers on things unnecessarily. I’d have the character handle everything and simply tell the weapon when to appear, disappear, fire etc.)