RPC ends up on synced player instead of the real remote player
Options
So, I have a PhotonView on my player that gets Instantiated.
The problem is that when I try to send an RPC to the same object on a remote client, the view IDs won't match and it ends up on a synced player, not the one that is controlled locally.
Any ideas?
The problem is that when I try to send an RPC to the same object on a remote client, the view IDs won't match and it ends up on a synced player, not the one that is controlled locally.
Any ideas?
0
Comments
-
Hi @nmkd,
the error message states, that there is no method marked with the [PunRPC] attribute. Please make sure to add this attribute to the function you want to call remotely. For example:[PunRPC] public void HandleSyncRemote(...) { }
0 -
I did that...Christian_Simon said:Hi @nmkd,
the error message states, that there is no method marked with the [PunRPC] attribute. Please make sure to add this attribute to the function you want to call remotely. For example:[PunRPC] public void HandleSyncRemote(...) { }
[PunRPC] void HandleSyncRemote(int id) { print("HandleSyncRemote called"); GameObject remoteGO = objectIndex.GetObjectWithID(id); customTransformSync CTS = remoteGO.GetComponent<customTransformSync>(); if(CTS == null){ CTS = remoteGO.AddComponent<customTransformSync>(); } CTS.isMaster = false; }
PV.RPC("HandleSyncRemote", PhotonTargets.Others, (int)CTS.myID);
...oh. Maybe I should've set it to public? Will try that now.
EDIT: It still ends up on my synced (non local) player, causing an error since I removed the script on that one.
I only want to receive it on my locally controlled player...
Edit 2: Another interesting thing: That wrong function gets called twice when I don't remove the script. So instead of being received on my local and synced player, I get it TWICE on my synced player...0