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:

1.) View ID SceneID: 0 Level Prefix: 0 not found during lookup. Strange behaviour may occur

2.) 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.

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 ! —>