- Home /
how to know that which client has left the game
i am making a multi player cards game. in which there are 4 players. my problem is that how can server find that which player has left the game. so that on rejoining the server server could send that data to that particular client. please help me!!!
It all depends on the networking setup you use, can you post some of your code about the conecting part?
void OnPlayerConnected(NetworkPlayer p)
{
if(Network.isServer)
{
NetworkViewID newViewID = Network.AllocateViewID();
if( p == null){
networkView.RPC("JoinPlayer", RPC$$anonymous$$ode.All, newViewID, PlayerObject.transform.position, p);
}
}
}
Answer by Lukas_Schwarz · Feb 09, 2015 at 04:12 PM
I'm not too experienced at networking in unity but there is a message called OnPlayerDisconnected with an NetworkPlayer parameter. API-Link
Answer by ghazza · Sep 29, 2017 at 04:42 PM
this worked for me
public override void OnServerDisconnect(NetworkConnection conn)
{
GameObject playerLeaving = conn.playerControllers[0].gameObject;
base.OnServerDisconnect(conn);
}
Your answer
Follow this Question
Related Questions
Unity Multiplayer Design. Is it complicated to implement and learn? 1 Answer
network player only flip on LAN Host not in Lan Client 1 Answer
Network Game - all players respond to same input 0 Answers
How to write a multiplayer game that uses a dedicated server? 0 Answers
Network : command doesnt work... 0 Answers