- Home /
Sending Network player info with RPC
Hi all, I'm having quite an issue an I don't really get it... In my situation I send from the server to the clients the list of players which are in game and operational, so they can send RPC to them as they are ready to handle them. But when a second client joins my game and my server sends to him the network player info of the first connected client the info sent by the server are not the same received on the other side.. Here are 2 screenshots, first on is what the server sends to the newly connected client :
the second on is what is received on the other side...
Anybody has a clue of what could be wrong ?
Thanks in advance
List item
Hi, yes I think there's an issue for posting images cause it appears I can't click on validate... Anyway here's the code of the sending and the RPC that receive it: /*The server sends to the newly updated client all the networkplayers that are in game. Like this clients and server are only sending RPC on clients that are in game and not to some remote connected client that are trying to join during a game already launched */
foreach(NetworkPlayer np in _DNetworkIdsToPlayers.$$anonymous$$eys)
{
foreach(int i in _DNetworkIdsToPlayers[np])
networkView.RPC("UpdatePlayerNumber", p_np, np, i,(int)_PlayersList[i]._Captain, _PlayersList[i]._bCharacChoosed );
}
/* Then on the client side we add this networkplayer to a list in order to adress the RPC directly to all the connected client that are InGame */
[RPC] private void UpdatePlayerNumber(NetworkPlayer p_NetworkPlayer, int p_iPlayerNumber, int p_iCaptain, bool p_bCharacChoosed) { if(Network.isClient && !_Network.bIsConnected()) return; if(_PlayersList[p_iPlayerNumber] != null) { _PlayersList[p_iPlayerNumber]._Captain = (PlayerProfile.eCaptains)p_iCaptain; _PlayersList[p_iPlayerNumber]._bCharacChoosed = p_bCharacChoosed; _PlayersList[p_iPlayerNumber]._bBeEdit = false; } if(!_DNetworkIdsToPlayers.Contains$$anonymous$$ey(p_NetworkPlayer)) { List l = new List(); l.Add(p_iPlayerNumber); _DNetworkIdsToPlayers.Add(p_NetworkPlayer, l); } else if(!_DNetworkIdsToPlayers[p_NetworkPlayer].Contains(p_iPlayerNumber)) { _DNetworkIdsToPlayers[p_NetworkPlayer].Add(p_iPlayerNumber); } }
The networkplayer ID reiceved is fine when it's the server's one, but when it's another client already connected, the id is correct but the ipAddress field is empty...
$$anonymous$$y concern is, after updating this ingame playernetwork list, when a client tries to send an RPC directly to another, the reicever gets errors about uncorrect viewID 0 not existing, but the rpc's are sent with correct networkviews that are not with id 0....
As far as I find out, whenever a NetworkPlayer is sent through RPC, it's only an integer.. The only thing is that as it's casted as a NetworkPlayer, it points to the local structure connections[] . So when you are on the client side, the structure connections[] contains only the info for the server, and this is why the networkID received is correct but all the IpAddress fields are empty... So basically, is it possible to send a RPC from a client directly to another client using
//This on a client directly to another client
NetworkPlayer otherClient;
networkView.RPC("foo", otherClient, ....);
I've converted your answers to comments - on UA Answer means Solution and not Reply - there's an add new comment button hidden on the right of the screen. Also your comments do not require moderation.
I believe you can send using the NetworkPlayer which can be a parameter to the RPC call.
Answer by Azran · Sep 14, 2012 at 12:29 PM
I cannot see your screenshoots, althought
Have you check if you use Buffered RPC?
no, I don't use buffered RPC, nor network.instantiate, nor network.Destroy. As I want that my connectec players receive the Gameplay RPC only if they are in game and not trying to joining it, I maintain an up to date list of players in game and sending the RPC directly between them. But I do think the problem is when a client sends an RPC directly to another client specific..
Your answer
Follow this Question
Related Questions
RPC a lot of lags (Photon) 0 Answers
Unity3d Network - Cant See Connected Players 3 Answers
Really quick/easy question about RPCs 1 Answer
Getting rotation to work on client 1 Answer
Network RPC 1 Answer