ARAnchor to improve tracking [ARFoundation]

Hi
Can anyone tell me if I can use the ARAnchor feature with ARFoundation?

If so, is there any documentation on its use?

Yes, we call them “reference points” in ARFoundation. There is documentation for adding and removing them here.

Awesome. Thanks. however that is the method documentation only.
Are there any actual code examples in the context of an actual application?

Hi guys

The sample doesn’t make use of “reference points” to place content on a plane… should/would using a reference point improve tracking so? what is best practice?

I asked this question here:

Thanks

I would hope so @GreeneMachine , I’m trying to figure these out myself too.

I’m trying to remove a reference point TryRemoveReferencePoint → but this takes the refPoint trackableID which seems not exposed, how do I get a refPoint trackableID? I tried to casting from the refPoint name but doesn’t work.

Cheers

There is a version which takes an ARReferencePoint.

Yay I miss that, so silly, thank you @tdmowrer !

Can I also please get your two cents, does this make sense: When the user moves an object that has an AR Ref Point I want to update the ARReferencePoint to this new location. So I’d delete the previous ARReferencePoint, creating a new one, and re-parenting the gameobject to this new point? I couldn’t figure out if there is a way to update the ARReferencePoint position to a new raycasted hitPoint which could save on performance.

Thanks a bunch for your thoughts!

Hello @tdmowrer

Unfortunately TryRemoveReferencePoint(ARReferencePoint) is freezing Unity.

Each time I racyast and touch I can create a ARReferencePoint.

I can store the ARReferencePoint and reparent an object to this point each time.
4583116--426823--upload_2019-5-27_7-44-24.png

But if I then add another line of code to actually remove the previous ARReferencePoint, Unity freezes, doesn’t crash but freezes indefinitely (code at end of post).

m_ARRefPointMgr.TryRemoveReferencePoint(prevRefPoint);

Console debug or VS Attach to Unity doesn’t show any results cos Unity freezes and can’t see what the problem maybe, can you please shed some light?

Thank you for your help, Sergio
Unity 2019.1.1f1, ARFoundation 1.1.0 preview.6, lwrp 5.6.1, XRRemoting 0.0.1 preview .10

sample code using ARRemote:
if (m_SessionOrigin.Raycast(ray, s_Hits, TrackableType.PlaneWithinPolygon))
if (spawnedObject == null)
{
spawnedObject = Instantiate(m_PlacedPrefab, hitPose.position, Quaternion.identity);
spawnedObject.transform.SetParent(m_CurrentRefPoint.transform);
Debug.Log(“Instantiated”);
}
else
{
spawnedObject.transform.position = m_CurrentRefPoint.transform.position;
spawnedObject.transform.SetParent(m_CurrentRefPoint.transform);
Debug.Log(“Current Ref Point: " + m_CurrentRefPoint + " Removing RefPoint:” + prevRefPoint);
m_ARRefPointMgr.TryRemoveReferencePoint(prevRefPoint);
}
prevRefPoint = m_CurrentRefPoint;

Hi @tdmowrer , using ARF 2.1 RemoveReferencePoint works :slight_smile:

One question to clarify the use of Anchors please: is it generally the case that after an initial anchor has been created and parented to an object that when moving the object a new RefPoint is created for the new position or rather keep using the initial RefPoint?

Thank you for your help, Sergio

ArCore doc says:
When anchoring objects, make sure that they are close to the anchor you are using. Avoid placing objects farther than a few meters from the anchor to prevent unexpected rotational movement due to ARCore’s updates to world space coordinates.

If you need to place an object more than a few meters away from an existing anchor, create a new anchor closer to this position and attach the object to the new anchor
@Tarrag

That’s very helpful, thank you @ArmanUnity :slight_smile:

One more question to the ARReferencePoint is how to scale the object inside the ARReferencePoint… what i have did is i have created ar reference point and put some game object inside it. but when i try to scale the origin then it doesn’t scale anymore.

Hi, There is a ARParticipantAnchor that represents another user in a multiuser AR experience in ARKit, You can see it here:https://developer.apple.com/documentation/arkit/arparticipantanchor?language=objc。
But I can’t find it in ARFoundation.I run the ARFoundation Demo. I still can’t find it. So where can I find it.

1 Like