I'm new to scripting and I'm trying really hard to make an AR application for Android mobiles in Unity3d. I came up to a problem, that cannot solve no matter what I've though off. 

Here is the situation. I have an AR camera scripted with the NyARToolkit plugin for Augmented Reality for Unity3d.

This AR camera, tagged as "MainCamera", needs to get switched off, when a certain distance is reached (meaning moving away the android phone) form the marker that renders the model on it.
When this distance is reached, I want to set off "MainCamera" and load another unity scene.

The following code is what I've tried so far, without much success. Need to mention that, this script is attached on "MainCamera", and this is the gameObject that needs to be disabled. 

Here is the script:

```
#pragma strict
 var mainCamera : Transform;
 var camera : GameObject;
 function Update() {
 var distance = Vector3.Distance(mainCamera.position, transform.position);
 if(distance<0) {
     Debug.Log("CloseUp camera is on : " + distance);
 }
  if(distance > 1) {
    Debug.Log("CloseUp camera is off : " + distance);
     Camera.main.gameObject.SetActiveRecursively(false);
   }
}

```

Can somebody, take a look at my code snippet and post a working edit, so I can get the distance right and set the camera off when user moves the android mobile away form the marker?

Thank you all in advance for your answers.

"Edit 1"

I know I'm not even close to the function need to make work on mobile, but this [link](https://itunes.apple.com/hk/app/rangefinder/id369171302?mt=8), will give you a view of that functionality. I need to get the distance from the marker to mobile first, and if that distance is e.g. above 1.5 m, the AR camera should be switched off and a new level should be loaded.