Develop

Colocation sample with Photon Fusion

Updated: Nov 9, 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

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. Create an App ID for Fusion 1, the version this sample bundles: sign in to the Photon dashboard⁠ with a Photon account, create a new app, choose Fusion in Select Photon SDK, and choose Fusion 1 as the SDK version. Copy the App ID of the app you created.
  3. Add the App ID to the AppIdFusion field in Assets/ThirdParty/Photon/Fusion/Resources/PhotonAppSettings.asset. This Fusion App ID is separate from your store app ID.
  4. Enable Shared Spatial Anchors in Quest settings
  5. Build and deploy to two or more Quest devices on the same local network