- Home /
RPC to specific clients Problem: networkView.RPC("SetPosRot", item._networkPlayer, pos, rot);
Hello,
I am making a networking game and in this game players can be in different scenes. So I want to send RPC to players who are in the same scene. First I send info of the chosen scene to all players with "networkView.RPC("SendPlayerInfo", RPCMode.All);"
In short All clients have the info of other players in a list named "ClientInfo.AllClientInfos".
And I try the following code on spawned object (player):
void Update ()
{
// movement code here
foreach (PlayerInfo item in ClientInfo.AllPlayerInfos)
{
if (item._gameType == GameType.GameType1 && item._networkPlayer != Network.player)
networkView.RPC("SetPosRot", item._networkPlayer, transform.position, transform.rotation.eulerAngles);
}
}
[RPC]
void SetPosRot(Vector3 pos, Vector3 rot)
{
transform.position = pos;
transform.eulerAngles = rot;
}
This works fine when I only have server and 1 client. But after more clients join, only server can see the changes of movements, other clients cannot see the movements. They can only see server movements and not moving spawned players of other clients.
Error messages on Client side when other client player spawned:
View ID SceneID: 0 Level Prefix: 0 not found during lookup. Strange behaviour may occur
Could't invoke RPC function 'SetPosRot' because the networkView 'SceneID: 0 Level Prefix: 0' doesn't exist
What I understand from this error is that client cannot find the spawned object Allocated ID and can't set its position which is not expected, because I see that it is there...
And one more thing, when I use the following code instead of sending RPC to specific clients, everything is work fine except the same error message when one of the client choose another scene (and this is an expected error, because in other scene there is no same type spawned object).
networkView.RPC("SetPosRot", RPCMode.All, transform.position, transform.rotation.eulerAngles);
So where do I do wrong? Any help appreciated.. Thanks in advance..
Note: I have checked all Networking examples. So I already done basic things such as AllocateID etc.
Sure I can.. But that would be better if someone answer like one of those: "You cannot send RPC from a client to other specific client using normal version of RPC. Only server can do it." Or: "You can send RPC from client to specific client. But you need to do......."
Answer by Fattie · Oct 25, 2012 at 03:47 PM
the answer is very simple, thank goodness .....
never, ever use the "first" version of the RPC call un Unity.
(just as you never use nonsense like "network instantiate"
Massive novel-length discussion ! --->
http://answers.unity3d.com/questions/326626/games-with-multiple-maps.html
http://answers.unity3d.com/questions/332027/call-a-rpc-on-all-clients-at-the-same-time.html
Thanks for the answer!) I have checked links. I already used "normal" version of RPC and don't use "Network.instantiate".
$$anonymous$$aybe I am wrong but it seems we cannot send "normal" RPC from a client to other specific client. So now I only send position info to server and then from server to all other specific clients.
you have to get the address, I mean the ID, FRO$$anonymous$$ the server (boss iPad) you know?
Yes I know.. I send new view IDs to all clients from server.. But I couldn't manage to send RPC from client to other client. (which is unnecessary for me now, because I handle everything on server then send RPC to other clients from server).
Your answer
Follow this Question
Related Questions
Does the position change need state synchronization? 2 Answers
Problem with Playmaker Send Remote Event 1 Answer
Is it "bad" to use RPCs to synchronize movement? 1 Answer
RPC with Network View 0 Answers
get return on networkView.RPC 1 Answer