Quantcast
Channel: Photon Unity Networking (PUN) — Photon Engine
Viewing all articles
Browse latest Browse all 8947

Using RPC as a normal Method Clarification

$
0
0
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

Viewing all articles
Browse latest Browse all 8947

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>