- Sort Posts
- 4 replies
- Last post
Re: ARcamera position?
June 8, 2012 - 10:50am #4
No. You need to reference the ARCamera
as such..
using UnityEngine; using System.Collections; public class ARCameraPosition : MonoBehaviour { GameObject cam; // Use this for initialization void Start () { cam = GameObject.Find("ARCamera"); Debug.Log( cam.transform.position.ToString() ); // you can simply use transform.position if the script is attached to the ARCamera } // Update is called once per frame void Update () { } void OnGUI(){ if( GUILayout.Button("ARCamera Position") ){ Debug.Log( cam.transform.position.ToString() ); } } }
Re: ARcamera position?
June 7, 2012 - 2:47pm #2
The distance can be found by comparing the ARCamera transform.position and the target's transform.position.
e.g.
float dist = Vector3.Distance(target.transform.position, arcamera.transform.position);
It's advisable to check this in the OnTrackablesUpdated callback on the trackable event handler. And the camera position is accessible from its transform.
Reply a little late.Thank you very much!