1.5 - Function Replication

An overview of the Network Features example level, example 1.5: Function Replication (Remote Procedure Call).

Choose your operating system:





In order to view both Server and Client perspectives, on the Play dropdown, set the Number of Clients field to 2.

In addition to variables, function calls can also be replicated. Replicated Function Calls can be set to either Reliable or Unreliable . Reliable calls are guaranteed to occur, while Unreliable calls may be dropped during heavy traffic. Most replicated functions that handle cosmetic visuals are unreliable to avoid network saturation.

There are 3 primary types of replicated functions: Multicast , Server , and Client . Multicast functions should be called on the server, where they are executed, and then forwarded automatically to clients. Server functions are called by a client and then only executed on the server. Client functions are called by the server and then only execute on the owning client.

Server and Client replication functions have an additional restriction that they can only be used on Actors that have a Net Owner . Actors have net owners if they are a player controller or owned by a player controller. Example: A pawn possessed by a player controller can have Server or Client replicated functions executed upon it.

In this example, a Multicast function handles a cosmetic event triggered from a button press.

Blueprint Breakdown

In the BP_Button_Multicast Blueprint's Event Graph (which is broken up into several pictures below), you will see in the first picture how Overlap Events are fired on both Server and Clients while the remainder of the script is only ran on the Server by using the Switch Has Authority node.

Click for full view

When the Button Pressed or Button Released custom events are called, since they are set to Multicast , they are fired for all clients so that everyone sees the script following the custom event and not just the player that initiated the event.

Click for full view of Button Pressed Event

Click for full view of Button Released Event

The result in-game is that both Server and Client(s) view the event that is triggered when pressing/releasing the button.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey