Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Object Tracking with ARKit on iPhone

Discussion in 'AR' started by nathanjams, May 11, 2024.

  1. nathanjams


    Jul 27, 2016

    Trying out the Object Tracking but need some guidance - new to iOS development.

    I have my prefab being instantiated into the scene when the world onject is detected however the object satys in a fixed position. Is it possible to anchor it to the world object as well?

    What I am trying to do is have a cup in the real world that is scanned by the phone and have a 3d model of the same cup appear in the scene. Ideally, I would like to be able to scale the virtial cup the real world cup and have the virtual cup constantly updating its position to match that of the real world cup.

    Is this possible? Any tips, links or suggestions on how to achieve this? Also, if there is a third party asset that does that even better.

    Much thanks in advance.
  2. andyb-unity


    Unity Technologies

    Feb 10, 2022
    Yes. If you are only tracking one object, a cheap way to do this is to set the Tracked Object Prefab field of the ARTrackedObjectManager.

    For multiple objects, you'll want to subscribe to the ARTrackedObjectManager's
    event, then choose which prefab you want to spawn based on which object was added. This event passes you an ARTrackedObject, then you should Instantiate your textured mesh prefab as a child of the ARTrackedObject GameObject to ensure that the mesh position is updated via tracking.