Is it possible that when calling:
RPC(string, NetworkPlayer, …)
it doesn’t support NetworkPlayer as parameter??
Maybe is just the version with RPCMode the one which supports it?
Is it possible that when calling:
RPC(string, NetworkPlayer, …)
it doesn’t support NetworkPlayer as parameter??
Maybe is just the version with RPCMode the one which supports it?
AFAIK, it only works on the server. You cannot directly send RPCs from players to other players. I might be wrong, though…
Jashan
No, sorry, I explained myself badly. I meant as a parameter, like in:
RPC(“RPCFunctionName”, targetPlayer, parameterPlayer)
You are correct Sir!
Yes, only the server has the correct NetworkPlayers’ infos. What I did was to have the server send a message to everyone with the NetworkPlayer of their opponents.
EDIT
Oh, and sorry, just saw that you were talking as a parameter, but it works, for example in my code I have (only in the server!):
networkView.RPC("sendPlayerNetworkInfo", RPCMode.Others, m_player.getUsername(), m_player.networkView.owner);
But you are using the RPCMode version! ;))
I was talking about the combination of sending to a NetworkPlayer using a NetworkPlayer as parameter:
networkView.RPC(“SendIt”, targetPlayer, parameterPlayer);
Oh, sorry, haven’t used that way.
well NetworkPlayer is a supported parameter type of RPC, and I don’t see why it should be dependent on which RPCMode you are using, as long as you have the right NetworkPlayer, which only the Server knows, as nafonso mentioned. Have you tested it? And it doesn’t work? Maybe Larus needs to drop by and confirm…
http://unity3d.com/support/documentation/Components/net-RPCDetails.html
Cheers.
It’s possible to use NetworkPlayer as a parameter in RPCs, also when using specific target players (not RPCMode).
This should work. I just tested something virtually identical to that. So, maybe its something else? What error are you getting?
I’m having troubles using RPCs to a NetworkPlayer.
It works if the sender OR receiver is the Server, but if I try to send from one Client to another, I get the following messages in the receiver’s Debug Log:
View ID SceneID: 64 Level Prefix: 0 not found during lookup. Strange behaviour may occur
Could’t invoke RPC function ‘sendLines’ because the networkView ‘SceneID: 64 Level Prefix: 0’ doesn’t exist
I got around it by sending everything through the server, and then the server sends to the specific NetworkPlayer.
As anyone experienced the same problem?
Regards,
Afonso
Hi Afonso,
AFAIK, you can only send RPCs directly to NetworkPlayers from the server. And it seems you can also send directly to the server using the “server NetworkPlayer”… Since all messages go through the server anyways, it’s probably no problem to send to the server and distribute from there (aside from being a bit more code ).
Sunny regards,
Jashan
Hi Afonso,
AFAIK, you can only send RPCs directly to NetworkPlayers from the server. And it seems you can also send directly to the server using the “server NetworkPlayer”… Since all messages go through the server anyways, it’s probably no problem to send to the server and distribute from there (aside from being a bit more code
).
Sunny regards,
Jashan
AAAAH thanks! Yes, I noticed that they went through the server, because only when the server browser window was active, the RPC would try to be called
This should be mentioned in the docs. Since it wasn’t, my server sent all the NeworkPlayers to everyone so they could interact directly. And when trying with only one client, everything worked, so with more clients I was getting very confused!
Now I’ll start winning more easily! I was the only one getting the lines of every player! hehe
Regards,
Afonso