Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question I would like a gameobject to follow its anchor as the "ANCHOR" moves in the scene. How to do this?

Discussion in 'AR' started by OrenD, Jun 26, 2021.

  1. OrenD

    OrenD

    Joined:
    Jul 14, 2020
    Posts:
    8
    Hello,
    I am new to AR.
    The problem I want to solve is how to instantiate a gameobject on my arm and have it move with the point on my arm that I selected as its initial pose. (meaning it needs to constantly update the gameobjects pose in relation to the initial point I selected on my arm, which also means it needs to somehow track that initial position I selected (via raycast) on my arm).

    Desired behavior example:
    Example: Forget my arm for a second, lets say I select a point on an apple in real life, a gameobject appears there, then as I move the apple (not the phone), the gameobject moves with it. Does that make sense?

    My approach:
    I initially want to select a feature point as a trackable to update on but reading about feature points, it seems it is not possible to use a specific one as a trackable. it seems this is not possible because it may only last for one frame, " A point cloud is considered a trackable, while individual feature points are not. However, feature points can be uniquely identified between frames as they have unique identifiers.

    https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@3.0/manual/point-cloud-manager.html

    Then I saw this on setting an Anchor. "A anchor is a particular point in space that you are asking the device to track. Some SDKs refer to these as "anchors". The device typically performs additional work to update the position and orientation of the anchor throughout its lifetime."

    https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@3.0/manual/anchor-manager.html

    This seems to be exactly what I want. However when I pass the initial pose to the ARAnchorManager and create an anchor, it does not do what I want it to do. i.e move the game object when I move the anchor.

    What it does do is instantiate the gameobject in the scene where I point, and then anchor it to that initial pose. It does not continually update the pose to the anchor as I'd hoped.

    I could use some insight on this one. There's probably also be some basic terminology and understanding I'm not yet aware of. Thanks in advance for any help!