Develop

Shared Spatial Anchor Sample

Updated: Apr 14, 2026
Note: Sharing anchors is available for UE 4.27 or later with Meta Quest 3 on SDK v59 or higher, Meta Quest 3S on SDK v71 or higher, Meta Quest Pro on v47 or higher, and Meta Quest 2 on v49 or higher.
The Shared Spatial Anchorssample project demonstrates the capabilities of Spatial Anchors and Shared Spatial Anchors. It provides example code for handling and maintaining spatial anchors, which you may reuse in your projects. The sample also uses Unreal Engine’s saving and loading systems to store the UUIDs of persisted anchors to app storage. You will need to follow these instructions to access the sample.
The sample implements a menu interface that uses event dispatchers to call functionality within the sample in a way that is easily scalable.
Shared anchor sample

Design

  • BP_MenuItem: The menu items are the interface actors of the menu. They contain the logic for the visual feedback of the current interaction and for calling the Event Dispatcher to run logic elsewhere in the project.
  • BP_Menu_Main: This menu handles all the general operations of anchors that don’t relate to individual anchors, such as creating, selecting, and loading anchors.
  • BP_Menu_Anchor: This menu handles all the operations specific to interacting with selected anchors. This includes saving, unsaving, hiding, and erasing selected anchors.

User Interactions

  • Move the thumbstick on the right Touch controller up and down to select menu items.
  • To create a spatial anchor, select Create Anchor and then squeeze the trigger.
  • To save a spatial anchor to storage:
    1. Go to Select Anchor.
    2. Point to the spatial anchor you want to save.
    3. With Select Anchor selected, squeeze the trigger.
    4. Select Anchor(s), and then press A. The anchor is saved to headset storage and to the Unreal save game.
  • To load saved Spatial Anchors back into the app in subsequent sessions, select Load Anchors.

Lobby

When first opening the app, you are placed into a waiting room with passthrough enabled. There is a menu attached to your right controller. There are two options.
  • Create Session: Selecting this option will create a new local network game session that you will automatically be connected to.
  • Find Session: Selecting Find Session will search for an available local network session that another local player created. If one is found, you will connect to it automatically, otherwise the text will turn red and you will stay in the lobby.
Note: Both headsets must be on the same local network for session discovery to work.
Lobby options

Shared Scene

After creating or joining a network session, you will be in a passthrough environment. A menu attached to your right controller has the following options:
  • Create Anchor: Selecting this option will create a new anchor, the position is defined by a preview anchor visible at the top of the controller.
  • Select Anchor: When hovering over an anchor in the environment, selecting this option will open a new menu specific to anchors.
  • Load Anchors: This option will load any anchors that were previously saved via the Save Anchors button.
  • Spawn Cube: Using this option will spawn a networked cube in the environment, it will spawn from the top of your controller.
  • Explode Cube: Using this menu option while hovering over a cube in the environment will shoot the cube up into the air.
Shared scene

Anchor Menu

After spawning and selecting an anchor, an extra menu attached to your right controller appears. This is the anchor menu. The default options are:
  • Save Anchor Locally: Saves the anchor to your local device.
  • Save Anchor to Cloud: Saves the anchor to cloud storage. After saving to the cloud, you can share the anchor with other users of the session.
  • Orient to Anchor: Makes the origin of the world the specified anchor. If you attempt to use this button with more than one anchor, the first selected anchor will be used.
  • Erase Anchor: Deletes the anchor from the scene, and if saved locally, removes the anchor from local storage.
Anchor menu

Local Storage

After saving the anchor locally, the following options appear:
  • Save Anchor to Cloud: Saves the anchor to cloud storage. After saving to the cloud, you can share the anchor with other users of the session.
  • Unsave Anchor: Removes the local anchor from local storage, but does not remove the anchor from the scene.
  • Hide Anchor: Hides the visual representation of the anchor from the scene but the anchor is still saved in local storage.
  • Orient to Anchor: Orients the entire scene to the selected anchor.
  • Erase Anchor: Deletes the anchor from the game world and removes it from local storage.
Local storage options

Cloud Storage

If you save the anchor to cloud storage, the following options appear:
  • Save Anchor Locally: Saves the anchor to your local device.
  • Hide Anchor: Hides the anchor representation. The anchor still exists but cannot be retrieved after restarting the app.
  • Share Anchors: Shares the anchor with any users connected to your session. The other connected users will automatically receive and load the anchors.
  • Orient to Anchor: Orients the entire world to the specified anchor.
  • Erase Anchor: Erases the anchor representation from the game world. This does not remove the anchor from cloud storage.
Cloud storage options