Quick RPC Question

.All = Everybody in the currently room?
.AllBuffered = Everybody in the currently room, and everybody that joins the room?

Do i got those correct?, and does those two only execute once?

Comments

  • Yes, you got those right.
    All RPCs are only executed once per GameObject. I think it's possible that multiple scripts on the same GO have the same RPC method though.
  • Do you know why this won't work?
    playerPhotons = GetComponent<PhotonView>();
    this.playerPhotons.RPC("SpawnWeapon", PhotonTargets.AllBuffered, "LandMine");
    
    [RPC]
    void SpawnWeapon (string weaponName)
    {
    	GameObject GO;
    	GO = PhotonNetwork.Instantiate(weaponName, Vector3.zero, Quaternion.identity, 0);
    	GO.transform.parent = rightHand;
    	GO.transform.localPosition = Vector3.zero;
    }
    

    When a player joins the room he can't see it, only the players in the room can see it, even though im using .AllBuffered?
  • This could be due to some loading or "game object creation timing" problem.
    Maybe the RPC is arriving and dispatched even before the GO and the script are existing??

    Check the console if some RPC fails cause it can't find the target.
    In the latest PUN package from the Asset Store is a PDF. It contains a section "Timing for RPCs and Loading Levels", which explains how to pause the message queue while a scene is setup. This might help.
  • I don't understand your logic Jesper, as I answered you in a previous post, this type of RPC shouldn't be buffered, because in a game, players are changing weapons often ! So with your method it will buffer ALL switchings EVERY players made from the start of the room.
    And PhotonNetwork.Instantiate shouldn't be used in your exemple : that is not appropriate.

    You just have to ask at the masterclient for the weapon handled by players when you join the room... that's all.
  • 2Kin wrote:
    I don't understand your logic Jesper, as I answered you in a previous post, this type of RPC shouldn't be buffered, because in a game, players are changing weapons often ! So with your method it will buffer ALL switchings EVERY players made from the start of the room.
    And PhotonNetwork.Instantiate shouldn't be used in your exemple : that is not appropriate.

    You just have to ask at the masterclient for the weapon handled by players when you join the room... that's all.

    Yes i understand now, and thank you. But i posted this before you gave me an answer in the other thread.
  • Ah ok, I didn't understand why you've asked this ! Sorry for that wizzle :oops:
Sign In or Register to comment.