This has me kind of pulling my hair out, especially because it seems the matchmaking/lobby features of UNet aren’t too well documented yet:
I have a custom NetworkLobbyManager, as well as a custom NetworkLobbyPlayer. Neither of these override or change anything about game player prefab spawning. When I “ready” all the players in the match, it transitions to the game scene correctly for all clients, but the player prefab is being spawned and replacing the lobby player on the host ONLY, not on any of the clients.
In the host’s scene, the lobby player has been replaced by the game player correctly, and the client is indeed connected to the match. However the weird thing is, on the client’s scene BOTH the host’s and client’s lobby player objects are still in the scene, as well as the host’s game player object, but that’s it. I can’t figure out why it won’t spawn game player objects properly on the client.
If anyone has any ideas let me know, thanks!
2 Likes
Some other potentially helpful info: OnLobbyServerSceneLoadedForPlayer is called on the host player, but not the any of the client players
1 Like
Figured it out. For anyone else who may have a similar problem:
My lobby manager had references to objects in the lobby scene which got destroyed on the transition to the game scene, leaving their slots as “missing” in the inspector. This was apparently causing the server to be upset and not work properly, so I made the objects DontDestroyOnLoad, and just disabled them at the start of the game scene.
1 Like
I am new to Unity. I have the same problem. where to put DontDestroyOnLoad? how to disable object? please explain how to do that.
Dinusha, it’s on the Lobby Manager script that you can download in Unity’s Asset Store. It is a prefab within that asset called Lobby Manager. DontDestroyOnLoad is a public static function that essentially keeps them (your objects) “alive” (not destroyed) on scene transitions.
You can call in the start method for each object you want to disable by using gameObject.setactive (false); This basically turns off those objects within that scene when it loads. This way you can turn it on and off as you need within that scene.