Log in or register to post comments

Getting Tracked Position of Phone

April 8, 2020 - 9:49am #1

I'm trying to get the position of the phone in real-time. I came across the positional device tracker, but it looks like that just returns a status of where the phone is and not the actual position. I need to then set the position of an object on a ground plane relative to the device's position.

 

Anything helps. Thank you!

Getting Tracked Position of Phone

April 11, 2020 - 3:23am #4

Hi,

you have to add the script to the ARCamera, then drag the Ground Plane and GameObject in the fields in the inspector panel.

Getting Tracked Position of Phone

April 10, 2020 - 3:35pm #3

Thank you!

Should I add that to the Ground Plane or the Game Object I want to display?

Getting Tracked Position of Phone

April 8, 2020 - 11:05pm #2

Hi,

you can get the position of your ARCamera (which represents the phone) by just adding a script like this to the ARCamera:

void Update()

    {

        Debug.Log(gameObject.transform.position);

    }

I'm not sure what you mean by 'relative to the device's position' but this script would keep your GameObject directly under your phone and always on the Ground Plane for example:

    public GameObject GroundPlane;

    public GameObject GO;

    void Update()

    {

        GO.transform.position = new Vector3(gameObject.transform.position.x, GroundPlane.transform.position.y, gameObject.transform.position.z);

    }

Don't forget to drag the Groundplane and the Gameobject on the Script. 

I hope that helps.

 

Log in or register to post comments