This document is about: FUSION 2
SWITCH TO

Fusion 2 Introduction

Overview

For a list of changes from Fusion 1.1 to 2.0 check this page.

Fusion is a new high performance state synchronization networking library for Unity. Fusion 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.

Under the hood, Fusion relies on a state-of-the-art compression algorithm to reduce bandwidth requirements with minimal CPU overhead. Data is transferred as partial chunks with eventual consistency. A fully configurable area-of-interest system is supplied to allow support for very high player counts.

Fusion is free for development. Start building today, launch your project and pay only when your game becomes popular beyond our free tier. Fusion's pricing enables small titles to grow big.

The Fusion API is designed to be similar to regular Unity MonoBehaviour code. For example, RPCs and network state is defined with attributes on methods and properties of MonoBehaviours 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.

Inputs, Networked Properties and RPCs provide the foundation for writing gameplay code with Fusion.

Using a Networked Property in Fusion:

C#

[Networked] public int lives { get; set; }

Defining and Setting Network Input for client-side predicted movement:

C#

public struct NetworkInputData : INetworkInput
{
    public Vector3 direction;
}

public class InputPollBehaviour : SimulationBehaviour, INetworkRunnerCallbacks
{
...
    public void OnInput(NetworkRunner runner, NetworkInput input)
    {
        var data  = new NetworkInputData();

        if (Input.GetKey(KeyCode.LeftArrow))
        {
            data.direction.x = -1;
        }
        // handle other directions

        input.Set(data);
    }
...
}

Using Network Input for client-side predicted movement:

C#

public override void FixedUpdateNetwork
{
    if (GetInput(out NetworkInputData data))
    {
        data.direction.Normalize(); // normalize to prevent cheating with impossible inputs
        _characterController.Move(5 * data.direction * Runner.DeltaTime);
    }
}

Declaring a Remote Procedure Call (RPC) in Fusion:

C#

[Rpc(RpcSources.InputAuthority, RpcTargets.StateAuthority)]
public void RPC_Configure(string name, Color color)
{
    playerName = name;
    playerColor = color;
}

Where Next?

Choosing the Right Network Topology

Fusion supports three fundamentally different network topologies with the same API as well as a single player mode with no network connection. We have a guide on choosing the best network topology for your game.

Within Fusion network topologies are called 'Modes'.

Network Topologies

Read more about Fusion's Dedicated Server, Client Host and Shared Authority Network Topologies

Tutorials

If you already have a good idea of what topology to use you can get started with the tutorials. Both Dedicated Server and Client Host have the same programming approach, so are covered by a single tutorial:

Back to top