- Home /
How to call NetworkClient.Ready() ?
I was looking at the doc to figure out how I can asynchronously load another scene from my current NetworkLobby game scene and I stumbled upon on NetworkManager.ServerChangeScene() NetworkManager.ServerChangeScene()
However in the description it says
Clients that connect to this server will automatically switch to this scene. This is called autmatically if onlineScene or offlineScene are set, but it can be called from user code to switch scenes again while the game is in progress. This automatically sets clients to be not-ready. The clients must call NetworkClient.Ready() again to participate in the new scene.
But I can't find any function named Ready() in NetworkClient class.
Now my first questions are
1) How can I call NetworkClient.Ready() function?
2) How can I asynchronously load a new game scene from my current game scene (which is in my case a loading scene)?
Answer by ChrisKurhan · Dec 03, 2017 at 03:18 PM
for #1: You can manage client's ready status on the Server by:`NetworkServer.SetClientNotReady(NetworkClient)` and NetworkServer.SetClientReady(NetworkClient)
https://docs.unity3d.com/ScriptReference/Networking.NetworkServer.html . On the Client you can do it with ClientScene.Ready()
https://docs.unity3d.com/ScriptReference/Networking.ClientScene.html
for #2. This is much more complex. As far as I know, when using Unity's default NetworkManager
you are forced to be on the same scene as the Server all the time, making loading screens/async scene loading difficult. The idea I'm playing with myself is:
Ignore the OnServerSceneChanged
& OnClientSceneChanged
events and manage the scene loading via custom NetworkMessage
s (https://docs.unity3d.com/ScriptReference/Networking.NetworkMessage.html) to tell clients to aysnc load a scene, then once Server has loaded that scene, allow scene activation on the clients.