Spatial anchors save holograms in real-world space between application sessions as ARPins. Once saved in the HoloLens’ anchor store, ARPin’s can be loaded in future sessions and are an ideal fallback option when there’s no internet connectivity.
[!NOTE] Anchor functions from UE 4.25 are obsolete in 4.26 and should be replaced with newer ones.
[!IMPORTANT] Local anchors are stored on device, while Azure Spatial Anchors are stored in the cloud. If you’re looking to use Azure cloud services to store your anchors, we have a document that can walk you through integrating Azure Spatial Anchors. Note that you can have local and Azure anchors in the same project without conflict.
[!IMPORTANT] Spatial anchors requires Microsoft OpenXR plugin.
The Microsoft OpenXR plugin must be used, available from the Unreal Marketplace or GitHub.
Before saving or loading anchors, you need to check if the anchor store is ready. Calling any of the HoloLens anchor functions before the anchor store is ready won’t succeed.
Once the application has a component you need to pin to the world, it can be saved to the anchor store with the following sequence:
Breaking this down:
When an application starts, you can use the following blueprint to restore components to their anchor locations:
Breaking this down:
Pin that actor to the ARPin from the anchor store.
The anchor ID is also queried so that different actors can be spawned depending on the anchor’s saved name.
When you’re done with an anchor, you can clear individual anchors or the entire anchor store with the Remove ARPin from WMRAnchor Store and Remove All ARPins from WMRAnchor Store components.
[!NOTE] Bear in mind that Spatial Anchors are still in Beta, so be sure to check back for updated information and features.
If you’re following the Unreal development journey we’ve laid out, you’re in the midst of exploring the MRTK core building blocks. From here, you can continue to the next building block:
[!div class=”nextstepaction”] Azure Spatial Anchors
Or jump to Mixed Reality platform capabilities and APIs:
[!div class=”nextstepaction”] HoloLens camera
You can always go back to the Unreal development checkpoints at any time.