Quantcast
Channel: Questions in topic: "measure"
Viewing all articles
Browse latest Browse all 91

Measure between 2 Objects & show in UI

$
0
0
Hi All, I have been looking all day for an answer to this and have found loads that just don't seem to work, I want to get/ display the distance between 2 objects. Eventually I would like to get the X/Y/Z values as well as the Vector3, that's why the other floats are in their. Below is what I have got so far and it seems pretty close, I'm just getting a null reference on Measure1, when I try and start the game. This is the closest I have got; Thanks For any help upfront... public class Measure : MonoBehaviour { //public GUIElement distanceText; public GameObject Measure1; public GameObject Measure2; public Text label; public float Distance_; //public float Distance_x; //public float Distance_y; //public float Distance_z; // Use this for initialization void Start () { } // Update is called once per frame void Update () { Distance_ = Vector3.Distance (Measure1.transform.position, Measure2.transform.position); label.text = Distance_.ToString ("F2"); } }

Viewing all articles
Browse latest Browse all 91

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>