This document is about: FUSION 2
SWITCH TO

Social Hub

Overview

The Fusion Social Hub is a technical sample that demonstrates how to make use of multiple topologies in one project, as well as how to implement logic so that it will execute differently for each specific topology while accounting for their inherent differences. The sample also demonstrates how to manage multiple NetworkRunners to transition between sessions.

This sample uses the following combination:

  • Shared Mode for the social hub in which many players can initially gather and interact with NPCs; and,
  • Host Mode session for dungeons which can be entered (i.e. created & started) from the social hub by a smaller number of players. In the dungeon, players can destroy boxes.

Controls

  • Host only: LMB to attack.
  • Both topologies: E to interact.

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 Real Time Settings (reachable from the Fusion menu).

Download

Version Release Date Download
2.0.0 Dec 08, 2023 Fusion Social Hub 2.0.0 Build 352

Connection Manager System

The Connection Manager is responsible for handling connection requests, as there will be more than one NetworkRunner to handle both topologies, it takes care of referencing the correct Runner and taking all necessary precautions not to get in conflict with the other.

App

The main purpose of this class is to perform networked operations that the ConnectionManager cannot because it is a Monobehaviour. On this sample it is only used to pass a RPC.

Connection Container

Is a simple c# class that holds references to a NetworkRunner, the ConnectionData currently used on that Runner, an App, the callbacks class of the Runner and some helpers checks.

Connection Data

A scriptable object that will be used to hold all the data needed to make a connection request to ConnectionManager. These are the main properties:

  • ConnectionID: ID referent to the connection, each unique session should have a different ID. It will be used as a session property to join or create a new session if none is available to join.

  • ConnectionTarget: It is used by ConnectionManager to know if the desired connection will be on a Shared or Host session.

Connection Gate

It contains a reference to a ConnectionData and will be used as an area trigger for toggling the interface to connect to the session defined at the ConnectionData.

Connection Manager

The ConnectionManager.cs will mainly perform the connection to the desired session, storing the reference to the correct ConnectionContainer based on the connection target received, besides some other utility logics.

Coding for both topologies

It is important to notice that some logics are going to work differently on different topologies, the best practice for provide support for both is to always check for Object.HasStateAuthority instead of Runner.IsServer, because it cover the state authority in Shared Mode and also the host or the server in Host/Server mode.

Also, using the Fusion Input, even if it is not really useful in Shared Mode, will make it work on Host/Server, like the PlayerMovement class.

For logics that are only supposed to run on a specific topology, Runner.Topology will return the topology that the NetworkRunner related to the NetworkObject is using.

3rd Party Assets

The Fusion Social Hub Sample includes several assets provided courtesy of their respective creators. The full packages can be acquired for your own projects at their respective site:

IMPORTANT: To use them in a commercial project, it is required to purchase a license from the respective creators.

Back to top