Develop

Colocation sample with Photon Fusion

Updated: May 10, 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

  • INetworkData — Interface for network data abstraction
  • INetworkMessenger — Interface for network messaging abstraction
  • FusionNetworkData — Photon Fusion implementation of INetworkData
  • FusionMessenger — Photon Fusion implementation of INetworkMessenger
  • State authority routing via HasStateAuthority check
  • Two-hop targeted RPC pattern for directed messages
  • INetworkStruct serialization wrappers for custom data types

Spatial anchor lifecycle

Create → Save to Cloud → Share → Localize → Align
  1. CreateOVRSpatialAnchor instantiation at a shared physical location
  2. Save to cloud — Persist anchor data for sharing
  3. Share — Make anchor available to other users
  4. Localize — Other devices find and resolve the shared anchor
  5. AlignAlignCameraToAnchor adjusts coordinate space

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

  • Quest with Horizon OS
  • Unity for Quest development
  • Photon Fusion 1 App ID

Getting started

git clone https://github.com/oculus-samples/Unity-LocalMultiplayerMR.git
cd 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