Search Unity

Handling Host and Client disconnecting

Discussion in 'Multiplayer' started by Karlthegus, Feb 5, 2016.

  1. Karlthegus

    Karlthegus

    Joined:
    Feb 25, 2014
    Posts:
    13
    I've set up a lobby with the NetworkLobbyManager, and as far as I understand, when you call either StopHost or StopClient, the client will disconnect, and reload the scene set as LobbyScene, is this correct? That's what it says in the manual for NetworkManager at least:

    "When the network is stopped, by stopping the server or host, or by a client disconnecting, the offline scene will be loaded. This allows the game to automatically return to a menu scene when disconnected from a multiplayer game."

    This caused my first problem, because my lobby is within the Main Menu scene, so when it reloaded that sane scene, everything that was set as DontDestroyOnLoad was duplicated of course, so for future reference, is it possible to change this behaviour so that it doesn't reload the scene?

    Now, that's not really a problem anymore, I changed everything around to load the DontDestroyOnLoad objects at runtime, and only do so if there aren't any duplicates, so that's okay. What is a problem however, is that it seems like when a client connects to a host, then disconnects, everything works as expected, but once the client connects a second time, and then disconnects, it does disconnect, but does not reload the scene. Has anyone experienced something like that before? Is there something I'm missing?
     
  2. Karlthegus

    Karlthegus

    Joined:
    Feb 25, 2014
    Posts:
    13
    Anyone know about this? I'm really stumped!