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
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 Services | Initialize UGS and authenticate a player to start a multiplayer game. |
| Create a session | Create a new session, configure its connection type, and define its initial properties to start a multiplayer game. |
| Join a session | Implement 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 host | As a session host, read, add, update, or remove session and player properties with several visibility options. |
| Manage properties as a client | Interact with sessions as a client by reading session properties and managing your own player properties with customizable visibility. |
| Session host migration | Learn about changing session ownership, including host election and data migration. |
| Network connection management | Players can create and join sessions using different network connection types and configuration options. |
| Matchmaking into a session | Implement different ways to matchmake into a session either using Unity Lobby or Unity Matchmaker. |
| Synchronize player names in a session | Expose and read player display names as session player properties so that all players can view each other's names. |
| Sessions observability | View real-time session information to debug active multiplayer sessions in Play mode. |
Additional resources
- Unity Gaming Services Multiplayer
- Netcode for GameObjects
- Netcode for Entities
- 👥 Community: Join the conversation on Unity Discussions