Develop

Shared Anchors sample overview

Updated: May 11, 2026

Overview

This sample demonstrates the full spatial anchor lifecycle using Blueprint visual scripting: creating, saving, loading, sharing, and erasing anchors across Meta Quest devices. It includes a lobby-to-scene flow, three storage states, LAN multiplayer via OnlineSubsystem, and controller-attached 3D menus for anchor management.

What you will learn

  • Create and manage spatial anchors using BP_SpatialAnchorManagerComponent
  • Persist anchors across three storage states: unsaved, local, and cloud
  • Share anchors between devices using the sharing API
  • Implement a lobby-to-scene multiplayer flow with BP_SessionManager and OnlineSubsystem
  • Persist anchor UUIDs across sessions with BP_SharedAnchorSaveGame
  • Orient the virtual world to a shared spatial anchor

Requirements

  • Two Meta Quest 2, Quest 3, or Quest 3S devices (required for testing sharing)
  • Unreal Engine with the MetaXR plugin
  • Git LFS (for large binary assets in the repository)
  • Developer dashboard Data Use Checkup configured for your app
For build setup and configuration, see the sample README.

Get started

Clone or download the sample from the GitHub repository. This repository uses Git LFS for large assets — ensure Git LFS is installed before cloning. Open the project in Unreal Engine with the MetaXR plugin installed. Complete the Data Use Checkup in the Meta Developer Dashboard for your application. Build and deploy to two Meta Quest devices on the same WiFi network. The sample opens to SA_Lobby where you can create or join a session.

Explore the sample

File / SceneWhat it demonstratesKey concepts
SA_Lobby (map)
Session creation and discovery
Lobby UI, multiplayer connection
SA_Showcase (map)
Anchor creation, sharing, and world alignment
Spatial anchor lifecycle, world orientation
BP_SpatialAnchorManagerComponent
Create, save, load, share, and erase anchors
Full anchor lifecycle API
BP_SessionManager
LAN multiplayer session management
OnlineSubsystem, session discovery
BP_SharedAnchorSaveGame
UUID persistence across app sessions
SaveGame pattern, anchor identifiers
Controller-attached 3D menus
Anchor management UI attached to controllers
3D menu pattern, context actions

Runtime behavior

The sample opens to SA_Lobby with options to host or join a session. The host creates a LAN session via BP_SessionManager using OnlineSubsystem, then transitions to SA_Showcase. The client discovers and joins the session over local WiFi.
In SA_Showcase, users create spatial anchors at their controller position. Anchors progress through three storage states:
  1. Unsaved: Exists only in the current session, lost on app restart
  2. Local: Persisted to device storage, survives app restart but not shared
  3. Cloud: Uploaded to Meta’s cloud, available for sharing with other devices
When an anchor is shared, the receiving device loads it and orients its virtual world to match the anchor’s position and rotation, establishing a shared coordinate system between devices.

Key concepts

Anchor lifecycle management

BP_SpatialAnchorManagerComponent encapsulates the full anchor lifecycle:
Create → Anchor exists in memory (unsaved)
Save Local → Anchor persisted to device (local)
Save Cloud → Anchor uploaded to cloud (cloud)
Share → Anchor shared with specific users
Load → Anchor retrieved from local or cloud storage
Erase → Anchor removed from storage

World orientation to anchor

When a shared anchor is loaded on the receiving device, the sample orients the entire virtual world to align with the anchor’s transform. This establishes a common reference frame so both devices see virtual content at the same physical location.

UUID persistence with SaveGame

BP_SharedAnchorSaveGame stores anchor UUIDs using Unreal’s SaveGame system. This allows the app to reload previously created anchors across sessions without requiring the user to re-create them:
// BP_SharedAnchorSaveGame stores:
// - Anchor UUID (for reload from local/cloud)
// - Storage state (local or cloud)
// - Creation timestamp

Extend the sample

  • Add anchor visualization with custom meshes placed at anchor positions.
  • Implement anchor-based content placement for shared mixed reality experiences.
  • Combine with the Colocation Discovery sample for automatic session discovery without manual IP entry.
  • Add anchor labels or metadata for organizing large numbers of anchors.