Documentation

Support

Multiplayer Services SDK

All Services

Multiplayer Services SDK

Integrate Multiplayer sessions

Implement multiplayer functionality in your games using sessions, a unified system that manages player connections and interactions.
Read time 2 minutesLast updated an hour ago

Note
The Multiplayer Services SDK uses sessions to manage groups of players. Sessions relies internally on different combinations of Unity Gaming Services such as Relay, Distributed Authority, Lobby, Matchmaker and Cloud Code, and thus contributes to the billing of those services.
Implement multiplayer functionality in your games using sessions, a unified system that manages player connections and interactions across multiple Unity Gaming Services. Sessions provide an abstraction layer for managing multiplayer game states, including initial player connections and gameplay interactions, and automatically handle complex multiplayer operations such as host election, players joining or leaving, and network connection establishment. A session represents a group of connected players and manages their interactions through various connection types, including client-hosted solutions like Relay and Distributed Authority, or dedicated game servers. Sessions work with either the Netcode for GameObjects or the Netcode for Entities networking libraries. Beginning with Unity 2022 LTS, developers can use session operations to create their multiplayer experiences. Instead of having to manually coordinate between the SDKs for Lobby, Matchmaker, and Relay, the Multiplayer Services (MPS) SDK merges the functionality previously spread across these individual services' SDKs into a unified API centered around sessions. For example, when creating a session, the MPS SDK automatically handles lobby creation, relay allocation, and manages the Netcode connection. Similarly, while joining a session, the MPS SDK manages lobby joining, and Netcode connection establishment. This combined approach maintains all the capabilities of the underlying Unity Gaming Services (UGS) Multiplayer services while reducing implementation complexity.

Topic

Description

Prepare your game for Unity Gaming ServicesInitialize UGS and authenticate a player to start a multiplayer game.
Create a sessionCreate a new session, configure its connection type, and define its initial properties to start a multiplayer game.
Join a sessionImplement ways for players to join an existing session, such as by using a join code or browsing a list of sessions.
Manage properties as a hostAs a session host, read, add, update, or remove session and player properties with several visibility options.
Manage properties as a clientInteract with sessions as a client by reading session properties and managing your own player properties with customizable visibility.
Session host migrationLearn about changing session ownership, including host election and data migration.
Network connection managementPlayers can create and join sessions using different network connection types and configuration options.
Matchmaking into a sessionImplement different ways to matchmake into a session either using Unity Lobby or Unity Matchmaker.
Synchronize player names in a sessionExpose and read player display names as session player properties so that all players can view each other's names.
Sessions observabilityView real-time session information to debug active multiplayer sessions in Play mode.

Additional resources

Important
Starting with Multiplayer Services SDK version 1.2, the default network handler implementation for Netcode for Entities automatically creates client and server worlds if none are available when starting a network connection through sessions.Older versions of the MPS SDK require you to create your Netcode for Entities client and server worlds before you can create or join a Multiplayer Services session. When you first add the Netcode for Entities package to your project, the default bootstrap automatically creates the client and server worlds at startup.For more advanced use cases, use a custom network handler to override the default integration with Netcode for Entities.