This document is about: FUSION 2
SWITCH TO

This page is a work in progress and could be pending updates.

Host Migration

Level 4

Overview

The Fusion Host Migration sample presents how to migrate the host in HostMode to another client after the original host dropped out of the session.

NOTE: For the full explanation of the Host Migration API please refer to the Manual page on Host Migration.

Photon Insiders Stream - Fireside Chat - Host Migration (01 mar 2022)

Upgrade Notes

This sample was originally created for Fusion 1.0, and the video above refers to that sample. That being said, the differences between this sample and the Fusion 1.0 version are minimal. Here are a few differences between the two:

  • NetworkTypeId: 'SceneNOSolver' in GameController.cs used to call NetworkObject.NetworkGuid; however, this no longer exists in Fusion 2.0. Instead, NetworkObject.NetworkTypeId is now used.
  • Prototyping Addon: The Prototyping Addon from Fusion 1.0 has been remove except for InputBehaviourPrototype

You can read more about migrating from Fusion 1.0 to Fusion 2.0 here.

Before You Start

To run the sample, first create a Fusion AppId in the PhotonEngine Dashboard and paste it into the App Id Fusion field in PhotonAppSettings (reachable from the Fusion menu). Then load the Game scene and press Play.

Download

Version Release Date Download
2.0.3 Sep 26, 2024 Fusion Host Migration 2.0.3 Build 666

Prefabs

  • GameController.prefab: responsible for controlling the game itself and performing the Host Migration.
  • FusionRunner.prefab: the Fusion NetworkRunner prefab with all that is necessary for Fusion to run properly. This prefab will be used to create the NetworkRunners when the game is running.
  • Goal.prefab: simple game objective, to where players should drag the interactable objects.
  • Interactable.prefab: the interactable objects that are pulled in the direction of players.
  • Player.prefab: player prafab.

Scenes

  • Game - The main scene of the sample, contains only the basic ground level and the necessary prefabs to run the Game. Once launched, it will show a Start Menu in order to start the Client and connect to a random game or create a new one.

Behaviours

  • GameController: this class is the main entry point of the sample. It is responsible for managing the NetworkRunners, connecting and creating sessions, but most importantly, performing the Host Migration. Check the code at GameController.OnHostMigration for more information.
  • GoalController: controller of the Goal prefab. It will detect the presence of an Interactable and call the logic to increase the score of Players.
  • InteractableController: controller of the Interactable prefab. It will check for any nearby player and move towards it as if it was being attracted by the player.
  • PlayerController: controller of the Player prefab. It will move the player based on the moving direction.
  • ConnectionTokenUtils: a set of utility methods to create Unique Tokens used by the clients to identify themselves.
Back to top