using System.Linq; namespace Mirror.Examples.TankTheftAuto { public class AuthorityNetworkManager : NetworkManager { /// /// Called on the server when a client disconnects. /// This is called on the Server when a Client disconnects from the Server. Use an override to decide what should happen when a disconnection is detected. /// /// Connection from client. public override void OnServerDisconnect(NetworkConnectionToClient conn) { // this code is to reset any objects belonging to disconnected clients // make a copy because the original collection will change in the loop NetworkIdentity[] copyOfOwnedObjects = conn.owned.ToArray(); // Loop the copy, skipping the player object. // RemoveClientAuthority on everything else foreach (NetworkIdentity identity in copyOfOwnedObjects) { if (identity != conn.identity) identity.RemoveClientAuthority(); } base.OnServerDisconnect(conn); } } }