- Home /
[UNET]Disconnecting from network doesn't destroy the player.
Hi, I am remastering the question made in 2012 to the actual system,
My player prefab is not being destroyed nor on disconnection and neither on client crash, I tryied to override the OnServerDisconnect function and test from a list where I save all players into classes if they are online.
I am using 2 systems to check if players are online and destroy them, both are not working. (I have a host based game, so everything is managed from clients and on the player network behavior I am using a lot of if(isServer)
to manage the game.
System 1 In NetworkManager_custom
public override void OnServerDisconnect(NetworkConnection conn)
{
Destroy(conn.playerControllers[0].gameObject);
NetworkServer.Destroy(conn.playerControllers[0].gameObject);
}
I am sure all connection can just have 1 controller
System2 In MyManager
public void Update()
{
if(isServer)
{
for (int i = 0; i < PlayersList.Count; i++)
{
if(!PlayersList[i].PlayerGameObject.GetComponent<NetworkIdentity>().connectionToServer.isConnected
&& !PlayersList[i].PlayerGameObject.GetComponent<ClientCommands>().ReturnLocal())
{
Destroy(gameController.players[i].PidgeonGameObject);
NetworkServer.Destroy(gameController.players[i].PidgeonGameObject);
}
}
}
}
Thanks in advice
Working as I removed the override, I am calling the functions now on the server when the players go TimeOut
Your answer
![](https://koobas.hobune.stream/wayback/20220612105046im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
Why the Network Health script is always null 0 Answers
Command method dont change variables on server 0 Answers
Understanding Unet attributes 2 Answers