Hi, Multiplayer Service SDK is a recent addition, but I found little information about its connection setup, like what is the difference between NetworkManager.Singleton.StartHost, that existed previously, and MultiplayerService.Instance.CreateSessionAsync (with relay network)?
I haven’t looked into it but I would expect the latter is a convenience feature since StartHost also requires you to call SetRelayServerData which is on the transport and perhaps some more things.
Assume the Services SDK is more tightly integrated with Unity Services.
Hi @Donkrokodil !
Thank you for jumping into our brand new Multiplayer Service SDK !
TL;DR: Indeed like @CodeSmile mentioned, the SDK (and by extension CreateSessionAsync
) is a convenient wrapper around Unity Services and most of the setup (including the network connection).
NetworkManager.Singleton.StartHost
is not deprecated and you can still use it when creating a game based on Netcode for GameObjects. It handles the network host listening and the connection from clients regardless of any service you might use. If you were to use Relay, you would have to use the Relay SDK and pass the relevant data to the UnityTransport component (see Use Relay with Netcode for GameObjects (NGO)). You would use StartHost
over CreateSessionAsync
to deeply customize your connection flow and the usage of all services involved and if you don’t mind writing the glue code between them.
The Multiplayer SDK introduces the concept of Session to encapsulate the glue complexity between various services (Relay, Matchmaker, Lobby, QoS and Multiplay Hosting, Distributed Authority) and handling the connection setup glue as well (both Netcode for GameObjects and Netcode for Entities). Please not that the Multiplayer SDK does include all the SDKs mentioned, so you can safely continue using them “raw” without any Session if you need to. You would use CreateSessionAsync
over StartHost
to easily get started and have all the connection glue code and setup handled for you with an easy customization of which services to include in the session lifecycle (direct connection, connection via code, connection via matchmaking, connection via session browsing, connection over Relay, …).
I hope it answered your question. The various documentation pages around this SDK as well as the standalone (Lobby, Relay, Matchmaker, Multiplay, …) SDKs should be updated in the following weeks. If you have any other questions or feedback on the Multiplayer SDK or the current documentation pages please feel free to voice them ! It will greatly help us identify weakpoints in our documentation that we might have missed.
I have also tried distributed authority topology with CreateSessionAsync
. Suppose that one player starts the session and subscribes to the NetworkManager.Singleton.OnConnectionEvent
callback to check if a new client is connected. When another client connects, the callback is triggered on the side of the session owner. session.Players.Count
property correctly shows 2 players, but NetworkManager.Singleton.ConnectedClientsList.Count
still shows only one player.