Spatial Anchors Not Tracking

Guys good day to you!

For some reason the Spatial Anchors do not seem to be tracking at all. I'm using the code in the link below & without the storage piece since I want to explain how they work before adding the persistent aspect of it.

I also simplified the Update method as shown below, but for some reason anchor.trackingState is always set to None? Normally this is either tracking or limited when I do exactly the same code on iOS devices.

private void Update()
    if (anchorManager.trackables.count > 0)
        Logger.Instance.LogInfo($"Trackable Count: {anchorManager.trackables.count}");

        foreach (var anchor in anchorManager.trackables)
            Logger.Instance.LogInfo($"{anchor.trackableId} {anchor.trackingState}");

I also have the AR Anchor Manager in the XR Origin, AR Anchor component is added to each instantiated anchor, Spatial_Anchor permission is added, and spatial anchor subsystem for OpenXR is also added.

What am I missing? Here's what I am using:

Version 1.7.0
Build B3E.240418.09-R.060
Android API Level 29
MLSDK 1.7.0
Unity Package 2.2.0
Unity 2022.3.31f1 LTS


There is something super strange happening with Unity 2022.3.31f1. For some reason the AR Anchor Manager is creating 2 ARAnchors even when I only instantiated one. I setup the exact same scene on Unity 2022.3.11f1 which is what the MagicLeap_Examples were built with and no issues.

Example of demo running in 2022.3.31f1:

Example of demo running in 2022.3.11f1:

As you can see, 2022.3.31f1 is creating a duplicate anchor, exact same code but different engine version. Any ideas?

Well spend all day on this :sweat_smile: but it turns out 2022.3.31f1 has issues when creating anchors. I literally downgraded to 2022.3.11f1 and same code, everything works well now.

I am not sure, perhaps a bad dependency somewhere.


1 Like

Happy to hear that you were able to solve your problem and thank you for the heads up regarding the newest Unity version. Let us know if you run into any other issues. :slight_smile:

Thanks Krystian.

One more question: do you by chance know why the "Spaces" app keeps the anchors even when they are deleted from storage within Unity? In my Unity demo I deleted them all, confirm its deletion by looking at the query results of 0 records, but for some reason the "Spaces" app still thinks they are there. Is this by design? or a bug?

Reporting the last issue here which I think is a bug. For some reason the confidence value is always set to NotFound, it doesn't matter if it is restored successfully from storage or not, it just never gets set to the other enums.

ulong magicLeapAnchorId = activeSubsystem.GetAnchorId(anchor);
MLXrAnchorSubsystem.AnchorConfidence confidence = activeSubsystem.GetAnchorConfidence(anchor);
anchorText.text =
    $"<color=green>AnchorId: {magicLeapAnchorId}</color>\n" +
    $"Confidence: {confidence}\n" + // this line here!
    $"Pos: {anchor.gameObject.transform.position}\n" +
    $"Rot: {anchor.gameObject.transform.rotation}\n" +
    $"State: {anchor.trackingState}";
anchorText.transform.Rotate(0, 180, 0);

Oops never mind, looks like it takes some time to report back, it just came back after a few seconds as "Low". It may be something to do with localization and what's happening behind the scenes.