Log in or register to post comments

ARcamera position?

June 6, 2012 - 7:41pm #1

ARcamera position and the distance to the model?using unity for ios.

Re: ARcamera position?

June 12, 2012 - 2:51am #5

Reply a little late.Thank you very much!

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 8, 2012 - 10:15am #3

How to know the location of the ar camera, Camera.main.transform.position? I contacted a very short time. Need help.

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.

Log in or register to post comments