Log in or register to post comments

[AnswerRequired]How to keep a 3D object fixed to initial position in AR world without following AR Camera

July 20, 2018 - 12:11am #1

Hi Vuforia Team,

I am following a GPS based application which evolves around GeoLocation get Coordinates logic.I want a markerless AR app which keeps a base 3D object fixed to the position wherever It is when app started to load and hat obect must not change it's position  in relation wit AR Camera.

Platform Details I am using:

Unity 5.4.3f1

vuforia 6-1-17



Inmy application I am uig an UFO obj hanging above at fixed position in the Unity Application.

Required functionality:the UFO must be static at the position wherever it appears on First loading of the AR scene.But THe UFO is not fixed to the initial position and it follows the camera like a faithul puppy.

Solution Folloed:I know some Unity logic to make an object independant of camera.

1.find the OBJECT_INITIAL_POSITION in awake or start function.

2.find the WORLD_DISTACE_FROM_CAMERA_TO_OBJECT_INITIAL in awake or start function.

2.In the upadte function find the WORLD_DISTACE_FROM_CAMERA_TO_OBJECT_RECENT.

3.Then shift object transform position by the differnce of these two values.

Technique used:

//in variable declaration

    private Camera m_CameraMAIN;

    private Vector3 object_initial_position;

    private Vector3 distance_from_camera_to_object_initial;

    private Vector3 distance_from_camera_to_object_updated;

//in start function

        m_CameraMAIN = Camera.main;

        object_initial_position = transform.position;

        distance_from_camera_to_object_initial = m_CameraMAIN.WorldToScreenPoint(object_initial_position);

//in update function

        distance_from_camera_to_object_updated = m_CameraMAIN.WorldToScreenPoint(transform.position);

        Vector3 diffDistance = distance_from_camera_to_object_updated - distance_from_camera_to_object_initial;



        transform.position = object_initial_position+diffDistance;

I know It is a bug in logic using WorldToScreenPoint on current position and shifting the same.And as expecte The object is lost.

But I am unable to try better solution for now as I am not fully introduced into Unity/Vuforia platforms.If any one of the exerienced programmers do it and share I am very happy to integrate it.

Thanks in Advance.

[AnswerRequired]How to keep a 3D object fixed to initial position in AR world without following AR Camera

July 20, 2018 - 9:07am #2

I'm a little confused on what you're after,  Not sure why you need screen coordinates at all. This tutorial may help you, it seems it's doing something similar: https://www.youtube.com/watch?v=X6djed8e4n0

If your looking for the UFO to get smaller, farther away and you walk away from it.  You're not going to get that without Vuforia7+/Ground Plane.  In addition you'll probably need ARKit or ARCore device for it to function really well.  

I suggest looking at all this person's videos on youtube, he may have other tutorials that may help as well.

Log in or register to post comments