I'm creating a 2D game for iOS. My game uses a host and client approach for a two player versus game in LAN. The host waits for a client then after loads the next scene. The problem is the scene loading is not synced for both players. The scene starts earlier than the other. I want to wait for all players to load the scene before any other work.
My NetworkManager has no online and offline scene assigned. No playerPrefab also because it will be added dynamically. I'm using ServerChangeScene(). I'm rather new to Unity and networking so any help is appreciated.
public override void OnServerConnect (NetworkConnection conn)
{
base.OnServerConnect (conn);
print ("OnServerConnect");
//not localclient(host)
if (client != null && client.connection != conn) {
ServerChangeScene ("PlayScene");
}
}
Okay since no answers, I handled this using custom messages. I made a loading screen that loads async the "PlayScene" and set its allowSceneActivation to false. When the client calls OnClientSceneChanged(), he will send a message to the server that its done loading the scene. The server will loop through all the clients to check if all have finished loading the scene and will reply that all clients are now ready for scene activation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With