Activating/Deactivating GameObject Problem :(

Im trying to diables my sniper when aiming down the sights but when i release the left mouse button the sniper does not re-activate.

Please Help.
C# Code…

using UnityEngine;

public class vp_FPSSniper : MonoBehaviour
{
	public GameObject Sniper = null;

	void Start()
	{
		Update ();
	}
	
	void Update()
	{
		if (Input.GetMouseButtonDown(1))
		{
			Sniper.SetActiveRecursively(false);
		} else {
			Sniper.SetActiveRecursively(true);
		}
	}	
}

If that script is on the object itself, then it won’t work.
The thing is, Update() is NOT called on inactive objects.

why are calling the update function from start? its done for you…

are you attaching this script to the object you are deactivating? if so you shouldnt because when you deactive an object you deactivate the script as well

You might want to try detecting the mouse Up

void Update()
    {
       if (Input.GetMouseButtonDown(1))
       {
         Sniper.SetActiveRecursively(false);
       }
       if (Input.GetMouseButtonUp(1))
       {
         Sniper.SetActiveRecursively(true);
       }
    }