Hello! I am working on a magic leap 2 app that is contingent on the ability to create and store spatial anchors for a very long time. Anchors that can be restored in the space months or even years after creation.
I have been using the example script provided here:
However I have been having issues with the storage functionality. The spatial anchor storage script does not properly store any anchors. Sometimes the anchors created in one instance of my application will persist until the next time I open the app (I tested this by creating anchors, closing the app and immediately opening again to check it), but not all of the anchors would persist, and none of the anchors would persist more than one time reopening the application (that is, if an anchor persisted and was visible after opening the app, closing and opening the app would cause that anchor to be permanently deleted). And I’m unsure what’s causing this issue.
I saw this post on these forums about issues with spatial anchor tracking in some versions of Unity.
I am currently working in this environment. 6000.0.023f1: 1.12.0: Android 10.0: Windows: 10
I have attempted to downgrade to Unity 2022.3.11f1 as the user suggested in his posts, however this downgrade creates a lot of errors. Is there any alternative to solve this issue? Is the example script deprecated in the current Unity updates?
Thank you.
(I should add, I have set up the AR anchor manager in the xr origin, ar anchor components on each new anchor as the script entails, and spatial anchor permissions are added, as well as spatial anchor subsystem for openXR added.)
Sorry you’re running into issues!
Luckily I have some suggestions that might help you.
The latest Magic Leap Examples Unity project is built with Unity 6 and includes an example scene with scrips that show how to create, store, and load anchors, so I would recommend checking that out to see if there is anything you might find useful in there. You can download the latest version (2.6.0) from the Magic Leap Hub 3.
You may already be doing this, but just note that in order to successfully create, save and load anchors, you need to be “localized” in your space. So ensure that you are localized before attempting to create and store anchors. You can find documentation and examples for this here Localization Map Examples | MagicLeap Developer Documentation
Please let me know if these suggestions help at all!
Thank you so much for your suggestion, it has been very helpful and insightful, I had neglected to check those Unity Examples, but they do run perfectly fine on the current version of unity and the version that I am running my project under, so it’s good to know that the issue is not with my unity version.
The spatial anchor storage example works perfectly when building directly from their examples, however I run into errors when inside my project, so the issue is likely caused by the environment. I was looking over the settings between both environments and found that this was the xr-plugin setup for the example project:
Naturally, I unticked magic leap and attempted to load the example within my project. It loaded fine and no visible errors were present, however I now have another issue. I cannot interact within the application. I am not sure if this is because I am building this app with MRTK3 plugins and there is some sort of conflict, but nothing works, the app accurately tracks my head and displays properly, but the controller does not work and neither does the hand tracking. This is what the openXR feature groups look like, this might be useful information:
Update: I figured it out, I simply forgot to enable the proper interaction profiles in the OpenXR section. It looks as if the example scene works perfectly within my environment now, and I can work this script into my application, thanks so much for your help!
Another Update! I was unfortunately mistaken, the interaction profiles fixed the issue of the controller not working, however the hand tracking and hand interaction simply will not work, even with these enabled interaction profiles.