However, when we late-join a new player, this happens: Which is great, we see the new mesh in all the players. Now, once we press E in one of our clients, this happens: For that, we execute a Multicast RPC from the server. In this example, we want to change the mesh of our character to SK_Mannequin. We are going to showcase the problems and convert it to a relevancy resilient code using the tools in our toolset. This Section provides an example of a relevancy non-resilient code. New connections have no clue which RPCs were sent recently. It can be useful for one-off events targetted to one specific client (ie: A team-mate sending you a private message).Įssentially, Multicast and Client RPCs are for one-off events, meaning that they don’t persist any state. Multicast RPC: Multicasts execute in all the clients, they are useful for one-off events, like one-shot SFX and VFX.Ĭlient RPC: Client RPCs execute only in the client to which the RPC is targeted to. Multicast and Client RPCs are one-off events that should be only executed from the server that trigger behaviour on all the relevant targets once called. This concept is key, as OnReps execute behaviour on clients when the value of such variable changes. The values of our replicated variables are sent by the server to the incoming connections, so if a new player becomes relevant to us, they will set our replicated variables to the incoming values. In addition, it is not possible to call explicitly the OnRep functions created by OnRep variables. However, the OnRep behavior will only be triggered on the clients if the variable of the OnRep has changed. The Server won’t trigger the OnRep, meaning that we have to call the OnRep behavior explicitly from the Server if we wish to execute it in the Server.īlueprints: When we set an OnRep variable in the server, the OnRep behaviour will be triggered always on the server (even if the value of the variable didn’t change). However, they don’t behave exactly the same in Blueprints and C++:Ĭ++: When changing an OnRep variable in the Server, the OnRep behavior will only trigger on the clients when the value of the variable changes. OnReps are replicated variables that trigger a behaviour on clients and server whenever the stored value changes. This post won’t get into low level details, but will provide insights on how Multicast/Client RPCs and OnRep variables work, for both Blueprints and C++, to provide late-joiners/relevancy “resilient” Multiplayer code. Most of the time this is because the lack of understanding on how RPCs and replicated variables work at a high level. One of the problems I’ve seen repeated lately in Unreal Engine is multiplayer code non resilient to late joiners and relevancy. In this post we explore a very typical conceptual problem I’ve seen a lot lately: Non resilient stateful multiplayer code. Unreal Engine - Correct stateful replication
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |