Log in or register to post comments

Track User's position in the Area Target

June 18, 2021 - 5:10am #1

Hello,

I am currently working on a tour app and I am trying to locate the user's position within the Area Target to display it on a minimap just like in this video (at 8:50) made by Vuforia to introduce Area Targets. 

For now, I have tried to display the AR Camera position on the minimap, which doesn't work quite well because the AR Camera position is relative to its initial position in Unity.

Does anyone has an idea on how I could proceed?

 

Thanks in advance :)

Track User's position in the Area Target

June 18, 2021 - 7:02am #2

The position of the AR camera does change with relation to the augmentations and position in the Area. Even if the origin is always at the AR camera GameObject, you still should be able to calculate the distance and direction from the AR camera to any point in the Area Target.

I thought about this but haven't implemented it in a Vuforia app but it might help you solve the problem.

- Create an empty game object in the Area Target, create an empty game object on some sort of a 2D floor map.

- Create a sphere as a child of the floor map game object.

- On runtime. calculate the distance/direction vector between the AR Camera and the GameObject in the Area Target.

- Set the transform of the sphere be equal to that same distance/direction but with respect to the empty game object on your 2D floor map.

- This should make the sphere and the AR camera move in synch. You then create another camera and render only the 2D map with the sphere.

Another approach would be to attach a 2D floor map as a child of the AreaTarget, or just use the Area Target model itself, attach a sphere to your AR camera object, yet again, create another top down view camera and only render the sphere and the map on it, while ignoring the rest. 

If you'd rather not use another camera, you will have to figure out a way to do the first approach but scale down and align everything, put the map on a quad texture and make it to always be in the screen space view/in front of AR camera.

I have used the the second approach successfully on Vuforia/AR unrelated 3D game and it should work here too, although I am not sure if multiple cameras are possible with Vuforia projects. Also. not a very experienced Unity/Game dev myself, so maybe this approach is trash and there is something much easier and more efficient.

Good luck!

Log in or register to post comments