
The Network_Features map inside the Content Examples project illustrates how to implement network functionality entirely through Blueprints. It provides key examples in Replication including the Replicates boolean which can be set on Actors, detecting Network Authority and executing different logic based on that authority, usage of Variable Replication and how it is used during gameplay, variable replication using RepNotify to execute logic based on updates made to a variable that is replicated, as well as the use of Function Replication to handle non-critical gameplay elements or "one-off" events.
The other section in the map provides insight on Relevancy and how to properly handle communicating information to and from the Server and Clients. Often times, it is not critical that every bit of information be passed from the server to every client (e.g. a player that is on one side of the map does not need to know about another player opening a chest on the other side of the map). There are situations when this would become relevant to that player however (e.g. if that player moved from the other side of the map to the chest that was opened), the Content Examples in this map will show how to handle situations like this as well as how to handle a player that joins an in progress session.
You can find additional resources on how an example was constructed by clicking on the example's name in their respective tables.
Replication
The examples in the Replication section showcase the methods of properly communicating information between Server and Client as well as when to employ the different techniques.
Example | What is Demonstrated |
1.1 Actor Replication | An example of two Actors where one is Replicated and the other is not (e.g. an Actor that shows up on both Client/Server and one that only shows up on Server). |
1.2 Detecting Network Authority and Remote Clients in Blueprints | An example of a Blueprint executing different logic based on Network Authority (e.g. Actor is displayed differently based whether its viewed on the Server or the Client). |
1.3 Variable Replication | An example of Replicating a Health variable from Server to Clients (e.g. an Actor's Health is displayed and updated on a Client as the Server updates the variable). |
1.4 Variable Replication (RepNotify) | An example of a variable that is marked as RepNotify which automatically updates on both Server and Client machines (e.g. A streetlight uses a RepNotify variable to ensure both Client and Server are viewing the same thing). |
1.5 Function Replication (RPCs) | An example of a Replicated Function is used to communicate when a button is pressed by the Server or Client. |
Relevancy
The examples shown in the Relevancy section demonstrate how to handle Network Relevancy for opening a chest and communicating the states between Server and Client. It solves a very common problem, how to handle the case where an Actor was irrelevant and then becomes relevant. This is very similar to the problem of handling a player who joins an existing game in-progress.
The examples below provide possible solutions to the problem stated above and why they would or would not work. The final example solves the problem by using a hybrid solution using multiple techniques.
Example | What is Demonstrated |
---|---|
2.1 Network Relevancy - Not Replicated At All | An example of relevancy where No Replication is used (e.g. Server opens a chest, Client does not see the chest as opened). |
2.2 Network Relevancy - Function Replication Solution Attempt | An example of relevancy where Function Replication is used (e.g. Server opens a chest, Client does not see the chest open and does not see it open when moving close to it). |
2.3 Network Relevancy - Variable Replication Solution Attempt | An example of relevancy where Variable Replication is used. e.g. Server opens a chest, Client does not see the chest open but sees it open when moving close to it. Particle effects also play, which is not desired for this example as the chest was previously opened by another player. |
2.4 Network Relevancy - Combination Solution | An example of relevancy where a combination of Function Replication is used to play the effects associated with opening the chest and a Replicated Variable is used to preserve the state of the chest and if it has already been opened or not. |