Network Project Configuration
Introduction
NetworkProjectConfig
is a Unity asset class to store Fusion's settings to be used on an individual game session. For client-server mode, the configuration is enforced by the server at runtime; in the case of shared games, the photon server plugin shares the configuration to be used.
There are many different settings, and some of them are exclusive (and others are mandatory) when using certain game modes. Examples: interest management settings will only have effect when using Eventual Consistency transfer mode; at the same time, Delta Snapshots mode is only available for client-server mode, etc.
Scene Settings
Peer Mode
Single
only one main active scene is loaded. Default configuration when running game builds.Multiple
multiple peers (server or clients) load their game scenes concurrently in the same editor/build instance. Mostly used for development/debugging.
Scenes
holds the list of scenes enabled in Unity's build settings. Fusion needs them indexed for automatic loading.
Physics Settings
Physics Engine
defines whereas Fusion should be responsible for stepping the physics simulation or not.Physics 3D
PhysX is stepped directly by Fusion withFixedUpdateNetwork()
.Physics 2D
Unity's Box2D is stepped directly by Fusion withFixedUpdateNetwork()
.None
Fusion does not step physics, which is handled by Unity. This normally is only used in games that do not need physics at all, or in a simpler shared-mode application.
Prediction Mode
Server Only
Physics is stepped only on forward new ticks from FixedUpdateNetwork. Resimulations do not affect the physics engines.Client Prediction
Physics is fully predicted (and rolled-back for server reconciliation) on clients. This is more expensive (due to PhysX scene resets) and should be used carefully in games that want to provide a WYSIWYG physics-sandbox experience.
Object Settings
Simulation
Tick Rate
Ticks represents discrete points in time and are decoupled from the "actual" time passing on any specific or host. For instance, if the tick rate is defined as 1/60th of a second, this is the timestep which will be used by the simulation. Using ticks instead of a hardware clock allows all participants in a network session to share a common frame of reference for "time". This is crucial to reason accurately about future and past events.
Behind the scenes Fusion will try to stay as true to the desired tick rate as it can; it may do micro-corrections to stay in sync with the correct tick time given by the server. Fusion will also do re-simulations where multiple simulation steps are executed in rapid succession to establish a new current state from an updated older state.
Replication Modes
The game's Replication Mode
, a.k.a. state transfer mode, is defined in the NetworkProjectConfig
asset's Simulation
section.
The APIs are identical for all replication modes, thus the same game and code can be used to run different game instances using different replication modes. This allows developers to choose or switch replication modes later in development.
Delta Snapshots
Delta Snapshots
are server authoritative and transfer full world-snapshots using an extremely efficient delta compression. Delta Snapshots
allow every client to continuously receive tick-accurate data. This is ideal for fast-paced competitive games with low player count (e.g.: 10 player team-based FPS).
This mode is only available for games started by a dedicated server or by a player-host (not valid for shared cloud games).
Eventual Consistency
The Eventual Consistency
mode adds Area of Interest, thus making it more suitable for games with a lot of NetworkObject
s and complex worlds (e.g.: survival and battle royale games).
Server Auth
:
This mode is only available for games started by either a dedicated server or by a player-host (not valid for shared cloud games).
Client Auth
: client authoritative EC is used for shared games over photon cloud. The area of interest is managed by the photon server plugin (automatically for all GameObjects with aNetworkTransform
orNetworkRigidbody
component).