mathf distance unity3d code example
Example: how to compare distance between 2 objects unity
float distance = Vector3.Distance (object1.transform.position, object2.transform.position);
float distance = Vector3.Distance (object1.transform.position, object2.transform.position);