Finding the distance between two points in 3D space using Vector3.Distance command
Code Used (Javascript)
-
var box : Transform;
-
-
function Update () {
-
-
var dist : float = Vector3.Distance(box.position, transform.position);
-
Debug.Log(dist);
-
-
if(dist <= 10){
-
light.enabled = true;
-
}else{
-
light.enabled = false;
-
}
-
}