Creating local world anchors on HoloLens 2

When HoloLens 1 was released, one of it’s greatest strengths was the ability to create persistent, so called world anchors, that would reliably lock objects into a position in the real world.

World anchors could be retrieved during later sessions, or even shared across devices! This was groundbreaking in 2015 and still pretty cool today.

With the HoloLens 2, the competition has caught up a bit and it is now possible to create spatial anchors on most AR/MR platforms. Still, the ability to create robust anchors using only the onboard device capabilities is an attractive feature of the HoloLens.

Microsoft are now pushing the use of Azure Spatial Anchors, which in many ways is a superior successor to the “old” spatial anchors. Created and managed by a cloud service, it leverages both the cached, local anchors, as well as an online database of anchors that can grow to host millions of anchors.

Still, sometimes it is preferable to use the classic world anchors, for instance, when you cannot, or do not want, to use any cloud services. I wanted to try if this was still possible, since the “WorldAnchorManager” script is available in MRTK (the Mixed Reality ToolKit).

Turns out that with some minor tweaks, it’s perfectly possible to create world anchors on HoloLens 2.

Based on these steps:, I wrote a small example app that enables the user to place a cube at any location, automatically creating and saving an anchor each time the cube is released. When the app is closed and re-started, the anchor is loaded and the cube is placed at its saved location.

The source can be found here:

Verified on Unity 2019.4.9f1, Visual Studio 2019, HoloLens 2 (Build 10.0.19041.1377).

In addition to the above steps, I added the base MRTK components, according to the MRTK getting started tutorial at . I also added a simple debugging prefab from this example: , and the manipulation handler from this example: