RPC problem[SOLVED]

Options
I have problem that when I send RPC, only the sending player seems to receive the RPC (boolean gets defined when received). I tested this by building for MAC + editor and for iOS + editor, same behaviour.

I have following setup:
- Network script in scene that I use to create room and instantiate characters.
- Character has controller script in parent game object with photonview component (not observed), this controller script sends the RPCs (Photon.Monobehaviour) .
Call:
this.photonView.RPC("RPCCall", PhotonTargets.All);

RPC function:
[RPC] void RPCCall()
{
RPCreceived = true;
}
- Character has also Synchronization script in same parent game object with photonview component (photonview observes this), used to sync movement and animation of characters, no RPCs here. OnPhotonSerializeView is here.

Any ideas what could be wrong?

Comments

  • I might have solved the problem, but still script is acting weird. Is it normal that RPC call does not work from OnCollisionEnter function?
  • vadim
    Options
    Hi,

    While client connected to the room, RPC called on PhotonView should work everywhere. Make sure that instances of your object exist on other clients (use PhotonNetwork.Instantiate() for character creation). Every instance should get RPC call.
  • I instantiate characters with this line, group for all is O. For every character I also instantiate controller (touch) in same way.

    GameObject newCharacter = PhotonNetwork.Instantiate ("CharacterPrefab", spawnHere.transform.position, Quaternion.identity, 0);

    During gameplay if I look to editor scene and two players there, the other player has controller script disabled (which is the one sending RPCs), but this should be ok as I only enable controller after instantiation (to be able to control each one separately). Just wondering if this is the root cause for RPC problem, should the script with RPC calls be enabled before instantiation?
    Is there any other simple tests I can do to find the root cause for problem?
  • vilpasan
    Options
    I have solved this. Root cause seems to be incorrect photon script location. I had script that was part of instantiated character and when I used this script to send RPCs, the RPCs were send and received but there was weird code behaviour because of photonviews. When I moved this script to be part of scene, everything works as intended. So character communicates with scene script and scene script does all the RPC sending/receiving.
  • Tobias
    Options
    Thanks for updating us and great you could find it in the end!