Develop

Colocation sample with Photon Fusion

Updated: Aug 25, 2026

Overview

This sample demonstrates local multiplayer in mixed reality using a three-phase colocation flow: matchmaking, connection, and alignment. It uses Photon Fusion for networking and Shared Spatial Anchors for spatial alignment between devices.

Three-phase flow

PhaseMechanismDescription
Matchmaking
UDP broadcast on port 9876
Discovers nearby players on local network
Connection
Photon Fusion
Establishes networked session
Alignment
Shared Spatial Anchors
Aligns coordinate spaces across devices

Architecture

These types are sample code, not Meta XR SDK API, so each one links to its source file.

Spatial anchor lifecycle

Create → Save to Cloud → Share → Localize → Align
  1. Create: place an OVRSpatialAnchor at a shared physical spot.
  2. Save to cloud: store the anchor so others can load it.
  3. Share: send the anchor to the other users. See Shared Spatial Anchors.
  4. Localize: the other headsets find and resolve the shared anchor.
  5. Align: AlignCameraToAnchor⁠ moves the camera by the inverse anchor pose, so the scene lines up with the anchor. For more on this pattern, see Deep Dive into Discover’s Colocation Package.

Network abstraction

// Interfaces allow swapping network backends
public interface INetworkData { /* state synchronization */ }
public interface INetworkMessenger { /* RPC messaging */ }

// Photon Fusion implementations
public class FusionNetworkData : INetworkData { }
public class FusionMessenger : INetworkMessenger { }

Migration note

Colocation package functionality has been ported to Multiplayer Building Blocks for SDK v65+. New projects should use the Building Blocks approach.

Requirements

  • Hardware: Quest 2, Quest Pro, or Quest 3
  • Development environment: Unity 2022.3.15f1
  • Photon Fusion 1 App ID
The sample project pins this Unity version. It is not the minimum for new Quest development. Unity Package Manager installs the Meta XR SDK packages when you open the project. For the pinned dependency list and build steps, see the colocation-sample-fusion source⁠.

Getting started

git clone https://github.com/oculus-samples/Unity-LocalMultiplayerMR.git
cd Unity-LocalMultiplayerMR/colocation-sample-fusion
  1. Open the project in Unity
  2. Configure your Photon Fusion App ID in the Fusion settings
  3. Enable Shared Spatial Anchors in Quest settings
  4. Build and deploy to two or more Quest devices on the same local network