Develop

CoLocationHS sample overview

Updated: May 11, 2026

Overview

The CoLocationHS sample demonstrates the older Shared Spatial Anchors approach (user-ID-based, not the Colocation Discovery API). It uses a two-phase architecture (lobby + showcase), BP_CoLocationComponent for anchor lifecycle management, passthrough with poke-a-hole materials, a Blueprint component architecture, device capability checking in C++, and targets UE 5.4.

What you will learn

  • Shared Spatial Anchors with user-ID-based sharing
  • Two-phase architecture (lobby and showcase)
  • Anchor lifecycle management via Blueprint components
  • Passthrough with poke-a-hole materials
  • Device capability checking in C++
  • Avatar representation in co-located experiences

Requirements

  • Meta Quest 2, Quest 3, or Quest 3S
  • UE 5.4

Get started

  1. Clone the repository.
  2. Open the project in UE 5.4.
  3. Configure app credentials in the Oculus Developer Dashboard.
  4. Deploy to two or more Quest devices for co-location testing.
  5. Start with the lobby phase to establish shared anchors.

Explore the sample

File / SceneWhat it demonstratesKey concepts
Lobby phase
Anchor creation and sharing
User-ID-based spatial anchor sharing
Showcase phase
Co-located interaction
Shared world alignment
BP_CoLocationComponent
Anchor lifecycle
Create, share, localize, destroy
Passthrough materials
Mixed reality rendering
Poke-a-hole technique
Device capability check
Hardware validation
C++ capability query

Runtime behavior

The app starts in the lobby phase where one user creates a spatial anchor and shares it with other users via their user IDs. Once all participants have localized the shared anchor, the experience transitions to the showcase phase where users interact in a shared coordinate space. Passthrough rendering uses poke-a-hole materials to reveal virtual content through the physical environment. Avatars represent each co-located player.

Key concepts

Shared Spatial Anchors (user-ID-based)

This sample uses the older user-ID-based approach for sharing spatial anchors. One user creates an anchor and explicitly shares it with other users by their Oculus user IDs.
Note: For new projects, consider using the Colocation Discovery API which provides automatic discovery without requiring user IDs.

BP_CoLocationComponent

BP_CoLocationComponent manages the full anchor lifecycle:
  1. Create — Generate a spatial anchor at the desired position
  2. Share — Send the anchor to other users by user ID
  3. Localize — Receiving users localize the shared anchor
  4. Destroy — Clean up anchors when the session ends

Poke-a-hole materials

Passthrough uses poke-a-hole materials that render as transparent windows into the physical world, allowing virtual content to appear embedded in the real environment.

Device capability check

A C++ capability check validates hardware support before enabling co-location features:
// Check device supports shared spatial anchors
bool bSupported = `UOculusXRFunctionLibrary`::IsDeviceCapabilitySupported(EDeviceCapability::SharedSpatialAnchors);

Extend the sample

  • Migrate to the Colocation Discovery API for automatic peer discovery
  • Add persistent anchor storage for returning sessions
  • Implement custom avatar representations
  • Add shared interactive objects in the showcase phase