Hi, I am developing an application that shows some objects within the space I am located in, every time I launch the app. I would like to use persistent anchors to use their position in space as reference and instantiate 1 object per 1 anchor.
I followed your guide on localization map, spatial anchor and spatial anchor storage and used your script to create the anchors. They are created correctly and I can see them in Spaces App, but I cannot figure out how to save the anchors and keep them in memory even after turning off and restarting the Magic Leap 2. If not possible through this method, could you please suggest me how to solve the problem? Thank you in advance
When you create an anchor, you can then get the ID of the anchor after it is published. Once published, the ID can be used as a reference inside your application.
For example, if you create an anchor, Anchor ID 1, then you can implement logic inside your application where Anchor ID 1 is the position of an object.
You will need to create the logic of binding and saving the logic yourself. You may want to experiment with creating a script that uses a JSON file that saves and loads a list of anchor IDs and some other information.
Thank you very much for the response. Actually, I tried a different approach that seems to have worked, and Iād like to share it in case it might help someone. Instead of using JSON files, I chose to export the map as a file with the anchors included, and the file is saved within the application folder (I followed the OpenXR Localization Map guide). After deleting the space from the device, and consequently all the anchors as well, I turned the device off and back on. Upon launching the application, I used code to import the map stored in the folder, and the space was successfully recreated, including all the anchors it originally contained. I hope this might be helpful to someone, thanks a lot.
1 Like