Many people just write you add an OnPlayerDisconnected function. In docs it says to just add it to a monobehavior. Yet no-one specifies where you add this function. I tried overriding NetworkManager but no go.
So where exactly do I place this function to make sure it’s called on the server? If players call disconnect they are removed from server ok. If the just close the app they hang around until NetworkIdentity starts throwing errors.
Here are the docs:
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
void OnPlayerDisconnected(NetworkPlayer player) {
Debug.Log("Clean up after player " + player);
Network.RemoveRPCs(player);
Network.DestroyPlayerObjects(player);
}
}