Log in or register to post comments

Find Distance and angle

September 13, 2016 - 3:52am #1

can i calculate real distance between marker and camera ?,

Find Distance and angle

September 14, 2016 - 11:39pm #3

I find the distance between imagetarget and arCamera but its return value more than 100 ..so its return true value ?  

Find Distance and angle

September 14, 2016 - 5:33am #2

Hi, in Unity I do it like this:

// Update is called once per frame
void Update () {
if (isTracking) {
  Vector3 delta = arCamera.transform.position - this.transform.position;
  float distance = delta.magnitude;
  Debug.Log("Distance to marker: " + distance);
}
}

Put this in a script which is on the ImageTarget

I hope this helps and is correct. I just searched for the part in an older project.

EDIT: Sorry this is only for distance. For Angle I guess you can do something with Dot product and the arCamera.transform.position or arCamera.transform.forward and as second parameter this.transform.position. Look it up. Someone has done it for sure.

Log in or register to post comments