ARCORE question regarding the cloning of the ImageTrackedPrefab and leaving it at its current coord

Hi everyone,

I am trying to clone (multiple times) the instantiated prefab from Tracked Image Manager and leave it in its current location at the time of a button click. The purpose of this is to produce a heatmap manually by using an OnClick event to take the prefab that is being tracked, clone it, and parent it to an empty GameObject that is parented to the AR camera. I’m doing the parenting in order to (hopefully) leave the cloned prefab at its current location so it isn’t tracking anymore.

The issue I am having is I cannot find the GameObject that is instantiated because ARCORE/ARFoundation gives it a random name in runtime that always appears to start with “ARTrackedImage” followed by alpha-numeric string.

Is there a way to clone any child of the GameObject “Trackables”, clone a gameobject by using a partial name with a GameObject.Find, or is there anyway that you can think of that will allow me to access the prefab instantiated on the TrackedImage to clone it?

Also, if there is abetter way to clone, Im open to other options. Im using Unity 2021.3.21 and ARFoundation/and ARCore 4.2.7

My attempt to do this is posted this to the main discussion board, and I think that it will work if I knew the prefab name in order to run a GameObject.Find:

Thanks in advance guys! Any help is appreciated.

Ok, I found this Runtime Inspector plugin which is super helpful for displaying the hierarchy and inspector in my app.

I am able to see that I am cloning the prefab that TrackedImageManager is producing (For anyone losing their mind on this ARFoundation naming the prefab name is the same as the prefab and ARFoundation adds “(Clone)” with no space next to the prefab name).

Its been a long day and my brain isn’t computing how the cloned position is correlating with my device camera. It appears to be placing the cloned GO very close to 0,0,0 relative to the device camera. That Im sure is a result of the cloned GO being parented to an empty GO that is a child of my camera. I see the values for position changing for each cloned prefab… but they are not visible to the camera because the coordinates are relative to the AR camera/Device Camera. Each of the clones has a separate and independent set of non-changing values for transform, scale, and rotation.

Some of my research is pointing to anchors. I don’t understand the anchors in ARFoundation enough to know what is happening. Is there a way to set or change the anchor from the child GO to my AR camera and set it to scene/world anchor so that when I move the image around the prefabs sit in different positions? Any help understanding these Anchors is very much appreciated!

Here you go! AR Anchor Manager component | AR Foundation | 5.1.5

We recommend that you upgrade to AR Foundation 5.1. This package isn’t visible in Unity’s package manager, but you can upgrade by following this article: Access AR Foundation 5.1 in Unity 2021 | AR Foundation | 5.1.5

AR Foundation 5 introduces XR Simulation, which allows you to see how the AR Foundation GameObjects work while running your app in the Editor. This should help you quite a bit with understanding how the Trackables GameObject works.

Using GameObject.Find at runtime is not a great idea for performance reasons. The more GameObjects you have in your scene, the longer this will take! You should subscribe to the imagesChanged event instead, and use the GameObject passed to you by ARTrackedImageManager when the image is detected. AR Tracked Image Manager component | AR Foundation | 5.1.5