- Home /
Question by
Riaan-Walters · Apr 20, 2016 at 11:15 PM ·
networkingplayerunity5kick
UNET - Kick player
Hi!
I've been digging for around 3 hours now, I cant seem to find a proper way to kick players from the server.
I've tried all combinations of these
NetworkServer.DestroyPlayersForConnection(player.connectionToServer);
player.connectionToClient.Disconnect();
player.connectionToClient.Dispose();
player.connectionToServer.Disconnect();
player.connectionToServer.Dispose();
but this does not seem to do the trick, and only causes exceptions in the NetworkServer down the line.
Could someone please share the proper way to do so? (because the docs on unet are hopelessly outdated)
Comment
Answer by Ender_7 · Apr 21, 2016 at 11:13 AM
The way I usually do this is through a call to the player objects network identity. Eg:
PlayerObject.GetComponent<NetworkIdentity> ().connectionToClient.Disconnect ();
Your answer
![](https://koobas.hobune.stream/wayback/20220612075253im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity Multiplayer - Instantiate prefab 1 Answer
UNET Matchmaking Filter Issues 1 Answer
UNET Players not spawning on server change scene 1 Answer
UNet ClientRPC does not fire 2 Answers
How do I find the player GameObject of the local player? 2 Answers