Using RPC as a normal Method Clarification

Options
Hello. After some testing, I noticed I could call an RPC as a normal method and didn't notice any issues with doing so. My question is if it's necessary for a master client to call an RPC as a normal method to avoid sending a packet over the network, or if it's okay to use an RPC for the master client to call an RPC to itself. I worded that awkwardly, so perhaps some code to use as an example will help:

// Option #1
if (PhotonNetwork.isMasterClient) DoStuff();
else photonView.RPC("DoStuff", PhotonTargets.MasterClient);

// Option #2
photonView.RPC("DoStuff", PhotonTargets.MasterClient);


[PunRPC]
private void DoStuff () { 
	// Stuff
}
If the above code is run on the master client, will option #2 send a packet over the network? Or will it treat the RPC as an offline method? Is option #1 even necessary? I'd like to minimize network messages as much as possible. Hope that makes sense.

Thanks in advance,
Muffles

Comments

  • Hi @MrMuffles,

    if the MasterClient uses an RPC targeting himself (PhotonTargets.MasterClient), no message will get sent, instead the MasterClient processes the RPC locally. However calling the desired function directly, might be more efficient.
  • MrMuffles
    Options
    Thank you for clearing that up for me. <3