- Home /
AR Kit 1.5 Track Image
With the latest AR Kit 1.5 the ability to find an image and get it's position, rotation etc has been added. I manage to have it find the image and place a model on it but if I move the image the model doesn't update its position/rotation. I have the following function as a callback on UnityARSessionNativeInterface.ARImageAnchorUpdatedEvent
void UpdateImageAnchor(ARImageAnchor arImageAnchor)
{
Debug.Log ("image anchor updated");
if (arImageAnchor.referenceImageName == referenceImage.imageName) {
anchorGO.transform.position = UnityARMatrixOps.GetPosition(arImageAnchor.transform);
anchorGO.rotation = UnityARMatrixOps.GetRotation(arImageAnchor.transform);
}
}
In the above code anchorGO is the model I'm trying to follow the image. The problem is this update callback isn't called very often (Once or twice after being found). I'm wondering if I can tell it to update more often or call for an update myself with specific intervals to find the image and get its position/rotation.
Answer by LimIndustries · Jun 08, 2018 at 11:02 AM
I came up against this issue as well. To solve it I had to set the dimensions of the physical image, I did this in xcode (although I think this could be set in the ARReferenceImage in Unity itself, it looks like you can be much more precise in xcode)
In xcode select the Project Navigator on the left of the interface, select images.xcassets from the list and then find your reference image. On the right side of the interface you will be able adjust the size and the units of the physical image.
After doing this I found the anchor be much more responsive when previewing it on a device.
I did make sure in xcode that my measurements were accurate but it still only called the function the first time it found the image. $$anonymous$$y work around was to have it remove the anchor for the image 10 times / frame and by doing so I forced it to find the image again and thereby call the function and repeat.
Your answer
Follow this Question
Related Questions
Disable an if statement in update 3 Answers
void update working under conditions 1 Answer
Updating app 0 Answers
[2D] Check if 2 parts are touching in an update loop? 0 Answers