기술 자료

지원

Multiplayer Services SDK

Multiplayer Services SDK

Frequently asked questions

Common questions concerning the Multiplayer Services SDK.
읽는 시간 2분최근 업데이트: 4일 전

What is the purpose of sessions, and how do they relate to the individual services?

The Unity Multiplayer SDK uses Sessions as a comprehensive wrapper to simplify the integration of Unity Gaming Services (UGS) backend features, such as Lobby, Relay, Matchmaker, and Multiplay, into multiplayer games. This single interface reduces boilerplate code and standardizes UGS usage, automatically managing features like Lobby heartbeating and, when enabled, the Lobby/Relay integration, allowing developers to focus on unique game features.

How does the Sessions API compare to the direct services API?

The following table compares the high level view for P2P Matchmaking when using Matchmaker, Lobby, and Relay individually versus using the Sessions API.

Direct services APIs

Sessions API equivalent

Host1. Create a Matchmaker ticket
2. Wait for the ticket to find a match
3. Create a lobby
4. Continuously heartbeat the Lobby
5. Create a Relay allocation
6. Add the Relay allocation ID to the Lobby host player
7. Start the NetworkManager
1. Start Matchmaking with Relay
Joining player1. Create a Matchmaker ticket
2. Wait for the ticket to find a match
3. Join the lobby based on the match ID
4. Join the Relay allocation
5. Add the Relay allocation ID to the Lobby player
6. Start NetworkManager
1. Start Matchmaking

Which APIs are deprecated?

The following standalone SDKs are depreacted:
  • Lobby:
    com.unity.services.lobby
  • Relay:
    com.unity.services.relay
  • Matchmaker:
    com.unity.services.matchmaker
  • Multiplay:
    com.unity.services.multiplay
The standalone SDKs are deprecated in favor of
com.unity.services.multiplayer
, their functionalities are still accessible within
com.unity.services.multiplayer
. Upgrade to the Multiplayer Services SDK by following the migration guide.

How does the session interact with the network?

Starting with version
1.2.0-pre.1
of
com.unity.services.multiplayer
, you can now choose when to start the network connection in your game flow. This isn't available with Matchmaking.
If you make the host use
WithRelayNetwork
,
WithDirectNetwork
or
WithDistributedAuthorityNetwork
when creating the session, then the network starts automatically as soon as the session is created. Any player joining this same session is pulled into the network connection automatically.
If you don't make the host use
WithRelayNetwork
,
WithDirectNetwork
or
WithDistributedAuthorityNetwork
when creating the session, then no network connection is automatically established. You can then execute any pre-match setup such as choosing a character or waiting for all players to be ready before establishing the network connection. No network is created for any player joining this session at that point. When the host is ready, they can use
StartRelayNetwork
,
StartDirectNetwork
or
StartDistributedAuthorityNetwork
to start the network. Any player joining this session after the network start is pulled into the network connection automatically.

Are there WebGL limitations?

The Multiplayer SDK supports the WebGL target, however, User Datagram Protocol isn't supported for this platform, consequently, Quality of service isn't available, neither is the Datagram Transport Layer Security encryption protocol for Relay. Broader limitations remain, even those unrelated to the Multiplayer SDK, such as restrictions on multithreading including the use of
Task.Delay
.

How is the Sessions API priced?

The Session API wraps multiple services into a single SDK. This includes Relay, Distributed Authority, Lobby, and Matchmaker and therefore contributes to the billing of each of those services. Refer to the Unity Gaming Services pricing page for complete details.

How do you enable verbose logging?

Set the
ENABLE_UNITY_MULTIPLAYER_VERBOSE_LOGGING
scriptable define under Script Compilation in the Player window of the Untiy Editor.

Would it be possible to matchmake to a session based on the best latency?

Quality of service (QoS) measurements are automatically used in the Sessions API when a player calls
MatchmakeSessionAsync
.