Matchmaking Basics
Sessions
When starting a NetworkRunner in a multiplayer mode it joins a "Session". A session is shared by multiple clients and has a unique SessionName
.
When starting a NetworkRunner
and passing in a SessionName
Fusion either joins that session or creates a new session if no session with that name exists yet.
C#
var networkRunner = GetComponent<NetworkRunner>();
var args = new StartGameArgs()
{
GameMode = GameMode.Shared,
PlayerCount = 10, // player count is optional and can be used to define the maximum amount of players in the session.
SessionName = "MyRoomName"
};
networkRunner.StartGame(args);
EnableClientSessionCreaton
can be set to False
to allow a client to only join and not create a session.
If no SessionName
is given in the StartGameArgs
the client will join any open session with space available and if none are available will create a new session with a random name.
Regions
Fusion Session's can be started in one of the available regions. Sessions exist on a per-region basis. When joining an existing Session via SessionName
it is crucial to ensure that the joining client is in the same region as the session.
By default, if no Region is set in the PhotonAppSettings
, Fusion connects to the Best Region
.
This means that during the start-up process, it pings all available Regions and connects to the region with the lowest ping.
Keep in mind that Best Region
is not deterministic and sometimes can be "random" due to little variations or exact same ping calculations.
An example for setting the Region
by code at runtime can be found here.
A list of all available regions can be found here
Advanced Matchmaking
Advanced matchmaking options are available in the full Fusion documentation.
- Authentication: We strongly recommend you implement this before releasing your game.
- Allowlist: We recommend you allow only a small amount of select regions on the initial release to minimize the segregation of your community. For instance (us, eu, asia).
- Lobbies: Lobbies can be used to list available sessions before joining a session.
- Custom Properties: Custom properties can be used for matchmaking. For instance by setting a "map" property to "map1" clients can filter to exclusively join session running the "map1" as their map.
- Quick Reconnect: Implement quick reconnect to allow your players to rejoin a session in case they disconnect.