Hi,

I got an array of players.
Each player has a boolean which indicate if he’s ready to start the game.
A pressed button make a RPC (RPCMode.AllBuffered) call for a function that toggle the boolean for this player.

My problem is, when the sender receive his RPC call,

NetworkMessageInfo.sender != Network.Player

Debug show that the NetworkMessageInfo.sender.ToString = -1 when Network.Player = 0 or 1 …

There is no problem for other players, they got the correct NetworkMessageInfo.sender (0, 1, …).
The result is when player click the button, everyone except him get it.

Did i miss something ?

Thanks for your time,

I believe what you’re experiencing is related to the slightly strange way that Unity3D deals with NetworkMessageInfo.sender. When the RPC call is received by the local player, nmi.sender is “-1”, rather than that player’s actual Network.player. This is really handy for knowing that it was sent by the local player, but it’s bloody useless if you’re using NetworkPlayers as an index to keep track of your players. Since you could easily tell if it was sent by the local player by comparing it to Network.player (i.e. if info.sender == Network.player), I think this behaviour is a bit silly.

Regardless, to handle this, at the top of your RPC method that receives the player readiness update you can do this:

NetworkPlayer sender = info.sender; 		
//handle the fact that unity is a bit dumb and calls the local player "-1" instead of its real networkplayer!!
if(sender.ToString() == "-1")
    sender = Network.player;

Then you can use “sender” instead of “info.sender” in the rest of that RPC, and it will have correctly handled the -1 to mean Network.player.

Thanks for your answer.
I already used something very close to your solution.
I think “if info.sender == Network.player” make more sense but well… it’s not a big issue.

Thanks for your time,