Question by 
               genericname24 · Aug 31, 2017 at 07:10 PM · 
                c#networkingmultiplayerserverdisconnect  
              
 
              How do you correctly remove a player that has disconnected from a game when using "OnServerDisconnect" ?
This is my current code for when a user disconnects(i am aware its a bit ugly at the moment) it is class that inherits from NetworkManager.However i am getting a message in the console that warns "Player not destroyed when connection disconnected". The client object seems to be destroyed on the host but i do get this warning.
 public override void OnServerDisconnect(NetworkConnection conn)
     {
         for (int i =0;i<3;i++)
         {
 
             if (humanPlayers [i].GetComponent<NetworkIdentity>().connectionToClient.connectionId+1 == conn.connectionId) {
                 Destroy (humanPlayers [i].gameObject);    
             }             
     }
I have see this code online for disconnecting a player but using OnserverDisconnect Conn i dont have a NetworkPlayer to pass to the methods
   Network.RemoveRPCs(player);
     Network.DestroyPlayerObjects(player);
     
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Unet - Where/How to start implementing Host Migration? 1 Answer
Photon & Unity Question 0 Answers
UNITY PROBLEM 2 Answers
API for multiplayer game with authoritative server? 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                