- Home /
UNet - When the host is ended all clients are kicked to lobby scene, how do I stop this?
I'm using the NetworkLobbyManager to implement my multilayer, and its caused me constant trouble due to the myriad of automatic things it does and doesn't tell you about anywhere in the docs. For the most part I've figured it out in the end, but I'm at a loss this time. When the host of a game disconnects I want the host to migrate to one of the clients; I've synced all relevant data (address, position, health etc) to the clients, paused the game make the clients wait a bit then connect to the new address etc, but none of that matters because the moment the clients get disconnected they are booted to the lobby scene.
I have tried overriding all overidable methods in my lobby manager (OnLobbyServerDisconnect, OnStopHost, OnServerDisconnect, etc) but no use. I've messed with all available settings, looked at dozens of forum posts and browsed the little documentation that there is for hours all to no avail. The closest I've got is that maybe ServerReturnToLobby() is called, but by what I have no idea and still probably not since the client is kicked to the lobby even when the host is uncleanly ended (internet dropping, alt+f4 etc.)
TL;DR: With a NetworkLobbyManager implemented, when the host of a multilayer game disconnects all clients are kicked to the lobby scene, how do I make it NOT do this?
Answer by gregorypierce · Oct 15, 2015 at 09:44 AM
Wait for unity 5.3 when host migration shows up. There isn't really a way to do it otherwise with uNet in its current iteration.
Cheers for the heads up, saves me banging my head against UNet for another 10 hours!
There are ways to do it but its very intensive and advanced. You basically reinitialise everything on a new server, provided all clients have access to some list to know which server they should be moving to.
Of course this is an ideal but you must consider that it is still the current host that must initiate the migration, so if for example you are running on Android, where apps are killed at a moments notice, there is most definitely not enough time for the disconnecting host to migrate the Server. To hold the app open for longer would probably be against Android's best practise and rules.
1 yr passed and in Unity 5.4 now, but the host migration seems only work for LAN but not match relay server....