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

Fusion Introduction


Fusion is a new high performance state synchronization networking library for Unity. With a single API, it supports two fundamentally different network topologies as well as a single player mode with no network connection.

It is built with simplicity in mind to integrate naturally into the common Unity workflow, while also offering advanced features like data compression, client-side prediction and lag compensation out of the box.

For example, RPCs and network state is defined with attributes on the methods and properties of the MonoBehaviour themselves with no need for explicit serialization code and network objects can be defined as prefabs using all of Unity's most recent prefab features like nesting and variants.

Behind the covers, Fusion relies on a state of the art compression algorithm to reduce bandwidth requirements with minimal CPU overhead. Data is transferred either as complete compressed snapshots (only hosted mode) or as partial chunks with eventual consistency. In the latter case, a fully configurable area-of-interest system is supplied to allow support for very high player counts.

Fusion implements a robust tick-based simulation and operates in either Shared Mode or Hosted Mode. The main difference is in who has authority over (ability to change) network objects, but this in turn dictates which other SDK features are available.

Back To Top

Hosted Mode

In hosted mode, whether running as a dedicated headless server or a combined client and server on the same device, the server has full and exclusive authority over all objects, no exceptions.

Clients can only modify networked objects by sending their input to the server (and have the server react to that input) or by requesting a change using an RPC.

Any change that a client does directly to networked state is effectively a local prediction and will be replaced with actual authoritative snapshots from the server when those are received. This is known as reconciliation as the client is rolled back to the server-provided state and re-simulated from there and back up to the local (predicted) tick.

If previous predictions were accurate, this process is seamless. If not, the state will be updated and because the network state is separate from the rendering state, the rendering may either snap to this new state or use various forms of interpolation, error correction and smoothing to reduce the visual artifacts caused by the correction.

In hosted mode, Fusion supports lag compensated hit boxes to account for the fact that each client sees other clients in the past and regular ray cast on the server would not match what the player was seeing. Lag compensation effectively allow the server to see the world from the players perspective at the time a given input was received.

When running hosted mode from behind a firewall or a router, the Photon cloud transparently provides UDP punch through or package relay as needed, but the session is owned by the host and will be lost if the host disconnects. Fusion does provide a host migration mechanism to allow transfer of network authority to a new client in the event that the current host is disconnected. Do note that, unlike Shared Mode, this requires special handling in client code.

Back To Top

Shared Mode

In shared mode, authority over network objects is distributed among all clients. Specifically, each client initially has authority over objects they spawn, but are free to give that authority to other clients. Optionally, clients may even be allowed to take authority at will.

In shared mode the data transfer mode is always Eventual Consistency, and features such as lag compensation, prediction and rollback are not available. Simulation always moves forward at the same tick rate on all clients, but beware that ticks are not guaranteed to be aligned between clients.

The Shared Mode network session is owned by the Photon cloud and remains alive as long as any client is connected to it. The Photon cloud serves as a package relay and has full access to the network state with no need to run Unity, allowing for lightweight server logic and data validation (e.g. cheat protection) to be implemented without the need to spin up dedicated server hardware.

Shared mode is in many ways similar to PUN, albeit more feature complete, faster, and with no run-time allocation overhead.

Back To Top

PUN, Bolt & Fusion Comparison

Fusion was developed to evolve and replace the two existing Photon state-transfer products for Unity (Bolt and PUN); it includes all supported architectures and more!

Although PUN and Bolt are solid networking solutions, their architectures do not allow for further optimizations. Fusion merges all the best concepts of both PUN and Bolt, while being built from the ground up with a high-performance architecture to enable state of the art features right out of the box. The following image summarizes the improvements.

Table - PUN vs Bolt vs Fusion
PUN vs Bolt vs Fusion

To Document Top