- Home /
NetworkManager.OnServerDisconnect not being called
Hello everyone, I will try to keep this nice and simple.
Basically I have a MonoBehaviour with a main class that inherits from the NetworkManager class. Inside this main class I have a NetworkManager.OnServerConnect and a NetworkManager.OnServerDisconnect.
The first one is called OK when the Client connects to the Server, but when the Client disconnects from the Server the second method is not called. Looks something like this:
public class UpdatedNetwork : NetworkManager
{
// Called on the Server when a Client connects to the Server.
public void OnServerConnect (NetworkConnection conn)
{
// The code in here runs fine when a Client connects to the Server.
}
// Called on the Server when a Client disconnects from the Server.
public void OnServerDisconnect (NetworkConnection conn)
{
// The code in here does not run when a Client disconnects from the Server.
}
}
Any ideas? Thanks.
Answer by Miscellaneous · May 06, 2016 at 03:48 PM
Maybe use override?
public override void OnServerDisconnect( NetworkConnection conn )
{
NetworkServer.DestroyPlayersForConnection( conn );
}
Answer by NFMynster · Aug 25, 2016 at 04:55 PM
I created my own disconnect method, that checks if the caller is the server and calls "StopClient" & "StopServer" accordingly. That way I could clean up after the disconnected players.
Your answer
Follow this Question
Related Questions
How can I receive which slider was selected 0 Answers
Player object on host can interact with objects, client players cannot. 0 Answers
How to synchronize disable and enabling game objects over the network? 0 Answers
Multiplayer desynchronize when grabbing an object by code. 0 Answers
How can I implement Client-Side Prediction and Reconciliation? 1 Answer