Hi there, Im using DontDestroyOnLoad(this) in a script and this script has also a OnPlayerDisconnected function.
This function calls throws an RPC.
At the server, the RemovePlayer function is called and works fine. But at the clients, Unity looks for the RemovePlayer function at another script (active at the current loaded level), not at the script RemovePlayer is declared.
Any clues?
I have no clue how they have implimented that method, but in reality, your client never calls that, the server calls it and then sends the request to the clients which in turn call it internally, but you don’t use it directly. The server knows when a player disconnects so then it sends the RPC out as a broadcast to the other players to say hey, this person is gone, get rid of them in your game view.
Look at the network example code to see how this is used.
Hye zumwatt I’m not sure you understood the problem.
OnPlayerDisconnected is only called at the server yes, and I’m having no problem with that.
function OnPlayerDisconnected(player: NetworkPlayer) {
networkView.RPC("RemovePlayer", RPCMode.All, player);
}
This function is only running at the server and is used to tell all (clients + server) that a player has left the game (and thus destroy all references to that player)
The problem is that the RPC calls can’t find the function “RemovePlayer” at the clients (at the server it works fine)