I created two default 3D cube objects in Unity’s Hierarchy. I added an ARAnchor script to one of them, and the other has nothing added. After building for the Android environment, both cubes don’t stay in one place and follow the camera’s movement, even though they are not children of the camera. Can anyone explain why this is happening?
Editor : 2022.3.35f1
ARFoundation : 5.1.5
Scene
- AR Session
- XR Origin (AR Rig)(Prefab)
-
- Camera Offset
-
-
- Main Camera
-
-
-
- XR Screen Space Controller
-
- Cube
- Cube (1) > AR Anchor(Script)
Hello randu123456,
One immediate problem that I see is that in order to have anything in the AR session properly track in the environment, it must be a descendent under the XROrigin – since that object represents the AR “world”
I highly recommend you try to run our samples within the Editor – using simulation – and watch the tracked objects come and go within the hierarchy and where they are, and what properties they have.
In addition to what @mike-copley-unity said, I would suggest try applying the anchor component to the cubes at runtime instead of in the inspector before you build. I haven’t tested your specific situation but the ARAnchors may not be getting added and tracked in the subsystem when you have them already applied to gameObjects at edit time because they may take some time before they can start tracking.
This is incorrect. The AR Session can be anywhere in the scene hierarchy. Apologies for the confusion.