Skip to content

schkrabrty/Photon-Fusion-Tutorial-With-Meta-XR-SDK

Repository files navigation

Networking-Tutorial-With-Photon-Fusion-2025

Photon Fusion Setup Guide

  1. Go to Unity Asset Store to https://assetstore.unity.com/packages/tools/network/photon-fusion-267958 to import Fusion package into your unity project.

  2. Download META All-in-One Sdk https://assetstore.unity.com/packages/tools/integration/meta-xr-all-in-one-sdk-269657 and imported into your folder

  3. Go to Photon Wesbite to create a account and go to Dashboard and hit Create new App

  4. Create a Fusion app: image

  5. Create a voice app too :image

  6. paste the Fusion app id in fusion dashboard:image

  7. If you cant locate this dashboard go to Asset/Photon/Fusion/Resources/PhotonAppsetting.Paste both the app ID and voice ID there and set the Region to US. image

Secene Demos

  1. Simple Grabbable Scene (using Meta Building Blocks) # what we showed on 10/02

    Drag the basic camera rig, interaction rig, and AutoMatching Manager into the scene.

    Create a cube and add the Grabbable component from the Interaction SDK.

    Assign Network Object, Network Transform, TransferOwnership Fusion, and TransferOwnership OnSelect to make the cube grabbable by two players over the network.

    Example: one player can grab the cube, and the other player will see the cube being grabbed; another player can also grab the cube directly from someone else’s hand.

    Note: gravity is not synchronized over the network. If one player grabs the cube from another player’s hand, there may be a visible offset — this offset only appears locally to that player

Remote Procedure Callback Tutorial

Why RPCs?

  • Network Transform / Network Mecanim Animator auto-syncs basics (position, rotation, scale, animations).
  • RPCs send small, custom messages (e.g., bool, int, float, string, Color) so every client runs the same update.
  • Docs: Photon Fusion RPCs

Example Goal

A cube changes to a player’s assigned color whenever that player points/touches it — and everyone sees the change.


Quick Setup

  1. Create the cube (optional: assign a default material).
  2. Add ray interaction: Interaction SDKAdd Ray Grab InteractionFix AllCreate.
  3. Network it: Ensure the cube has a NetworkObject component and check Allow State Authority Override.
  4. Add scripts/components:
    • Interactable Unity Event Wrapper (exposes hover/select events).
    • NetworkInteractableUnityEventWrapper.cs (inherits Fusion.NetworkBehaviour). You can get this script from the .zip file that I shared with you on Slack.
    • In the Inspector, go to NetworkInteractableUnityEventWrapper component and:
      • Set Ray Interactable → child ISDK_RayGrabInteraction from the interactable cube that you just created (or drag and drop this gameobject).
      • Set Target Renderer → cube’s MeshRenderer (or simply drag and drop the cube gameobject).
      • (Optional) A UI text field for on-cube tips. Feel free to comment out line 15 and 80 from the NetworkInteractableUnityEventWrapper.cs script if you do not want to use the text field. I used it for guiding the players about how to interact with the cube. Feel free to open the Grabbable + Interactable Cubes with Better Avatar Scene and expand the Interactable Cube to see the canvas where I created a UI Text Mesh Pro text game object. I dragged and dropped this text game object in the text field of the script.

How It Works

  • On hover start: temporarily take ownership → look up the player in a dictionary.
    • If new: generate a random color and store {playerId → color}.
    • Apply that color locally, then send an RPC so others mirror the change.
  • On hover end: release ownership.

RPC Basics

[Rpc(RpcSources.All, RpcTargets.All)]
public void RpcSetColor(Color color) { /* apply color */ }

Sources / Targets

  • All — any player can call / everyone receives
  • InputAuthority — the player currently controlling the object
  • StateAuthority — the player who currently owns the object’s state

In Shared GameMode, All → All is a safe default for this use case (adjust if your GameMode differs).


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors