Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

StopHost removes player objects that it is not supposed to

Discussion in 'Multiplayer' started by Twitwi, Jul 28, 2016.

  1. Twitwi

    Twitwi

    Joined:
    Apr 11, 2012
    Posts:
    22
    I am working on a game that requires exactly 4 people. Because of that my current lobby scene has the 4 lobby player objects instantiated (so not spawned as the clients connect, but already there and then assigned as the clients connects).

    This works if not for one issue, when a player disconnects, the player's lobby player object gets removed. It would seem that I should override some inherited method from NetworkLobbyManager/NetworkManager, so here is what I have written:
    Code (CSharp):
    1. public override void OnServerDisconnect(NetworkConnection conn) { /* nuked */ }
    2. public override void OnStopServer() { /* nuked */ }
    3. public override void OnLobbyStopHost() { /* nuked */ }
    4. public override void OnStopHost() { /* nuked */ }
    5. public override void OnStopClient() { /* nuked */ }
    6. public override void OnLobbyStopClient() { /* nuked */ }
    7. public override void ServerChangeScene(string sceneName) { /* nuked */ }
    8. public override void OnServerRemovePlayer(NetworkConnection conn, PlayerController player) { /* nuked */ }
    This fixes it for all the clients, though it throws a warning, even though this is the intended behaviour.


    However the Host's lobby player object still gets removed

    How do I fix this? Is it even possible? The Unity Networking doesn't seem to have accounted for this use case.

    I've also had other Unity Networking issues (that have gone unanswered) check it out here: http://forum.unity3d.com/threads/canvas-misplacements-duplication-issue.418070/