Sunday, July 26, 2020

RaiseEvent vs RPC in PhotonEngine

https://forum.unity.com/threads/rpcs-vs-raiseevents.573007/

Generally speaking the easiest way to instantiate networked objects is by using PhotonNetwork.Instantiate, or PhotonNetwork.InstantiateSceneObject.

You can use RPCs or RaiseEvent to achieve the same, but then you need to manually do a lot of stuff that is automatically taken care of for you by PhotonNetwork.Instantiate, such as allocating viewIDs and cleaning up when a player disconnects.

The only advantage of RPCs over RaisEvent, in my opinion, is simplicity as there is less work required to get them working, but the con is that they require objects to have a PhotonView attached.

RaiseEvent on the other hand is much more flexible in as much as no PhotonViews are required and you decide which scripts will listen for and respond to them. You also have greater control over which clients you send to, which can save bandwidth.

I don't use RPCs at all now, preferring RaiseEvent for everything.

This is just fairly general personal opinion on my part, if you require more specific help you should post some of your code with a description of what you want it to do vs what it is actually doing.

No comments:

Post a Comment