Hey guys,
I’m creating a client/server game where one of the players act as a server and the other as a client.
I have one GameObject that is not destroyed between scenes and contains all RPC functions. I DO NOT create and sync it with NetworkView. I just call RPCs between client and server.
Here is the situation I’m getting into:
- Server hosts a game to MasterServer
- Client see it and connect to it
- Game starts
- Server dies (the app is closed) - All clients return to List of games scene
- SAME SERVER PLAYER launches and hosts the app again
- Clients see the new game, connect again
- ------- Each client’s OnConnectedToServer is now called twice
If the server dies again, host another game and the client connect again, now the OnConnectedToServer is called three times!
Am I missing something? Do I have to call something to clear… something?
I tried the following:
private void OnDisconnectedFromServer()
{
Network.RemoveRPCs(Network.player, 0);
Network.RemoveRPCs(Network.player, 1);
Network.RemoveRPCs(Network.player, 2);
Network.RemoveRPCs(Network.player);
Network.RemoveRPCs(this.networkView.viewID);
Network.RemoveRPCsInGroup(0);
Network.RemoveRPCsInGroup(1);
Network.RemoveRPCsInGroup(2);
Network.DestroyPlayerObjects(Network.player);
StartCoroutine(LoadScene("Title"));
Network.SetLevelPrefix(0);
}
None of this does anything.
Thank you in advance.