- Home /
RPC function order
Hi guys:
I have a question with the execution or receiving order of RPC function calls. Basically what I wanna to achieve is, each player should have a list of the players of the game, and the order should be the same, say player1 (because he is the host so he is the first one in the list), player2 (he is the first one who joined this game, so the second one in this game), etc.
My code is like this:
void OnServerInitialized() { networkView.RPC ("RPC_SharePlayerInfo", RPCMode.AllBuffered, playerName); }
void OnConnectedToServer() { networkView.RPC ("RPC_SharePlayerInfo", RPCMode.AllBuffered, playerName); }
[RPC] void RPC_SharePlayerInfo(string name, NetworkMessageInfo info) { players.Add (name); }
So what I expect is, after player2 join the game, the buffered RPC_SharePlayerInfo sent by player1 should execute, then the RPC_SharePlayerInfo sent by player2(himself) should execute.
But from what I see in the test, the RPC_SharePlayerInfo sent by the player himself always get executed the first, and then all the buffered call from other players.
Why it's like that? Is there a way to achieve what I want?
Thanks you in advance.
Your answer
![](https://koobas.hobune.stream/wayback/20220613120435im_/https://answers.unity.com/themes/thub/images/avi.jpg)