How can a gameobject be deactivated if it is "seen" by the crosshair?

I know it should be done with raycasting method but I don't get the point on making it works... Any idea?

Thanks

You need to do something like this:

  1. Add colliders to the gameobjects.
  2. Use Camera.main.ScreenPointToRay to create a ray from crosshair into world
  3. Use Physics.Raycast to find out what you're hitting
  4. Use SetActiveRecursivly on the gameobject the found collider is attached to to disable it

EDIT: okay, some code to help you:

function Update () {
    if (Input.GetButtonDown("Fire1")) {
    	var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    	var hit : RaycastHit;
    	if (Physics.Raycast(ray, hit)) {
    		// hit will now contain info about the object clicked upon
    		hit.transform.gameObject.SetActiveRecursively(false);
    	}
    }
}