2.4 - Network Relevancy [Part 4 - Combination Solution]

An overview of the Network Features example level, example 2.4: Network Relevancy (Part 4 - Combination Solution).

Windows
MacOS
Linux
On this page

2_4.png

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

Both examples 2.2 and 2.3 failed beacuase neither could handle the two cases the chest examples needs:

  • To play an instanteous effect at the time of interaction.

  • To preserve a change in state in the Actor over time.

Example 2.4 provides a hybrid solution by combining the use of the techniques used in 2.2 and 2.3 to effectively solve the problems. The Multicast function handles playing the instant gold effect for clients relevant at that specific time, while a replicated boolean preserves whether the chest lid is open or not. If the chest was not relevant for a client during the initial opening of the chest, the client will only see the lid open when the chest becomes relevant to them.

Blueprint Breakdown

In the BP_Relevancy_Replication_Combined Blueprint's Event Graph, as seen in the commented section below, the OnChestTouch is overriden to use a combination of a RepNotify variable and a Multicast replicated function.

2_4_Eventgraph.png

Properly displaying the chest has two components: one that is instantaneous (the gold particle) and one that is persistent state (the lid being open). The Multicast is employed to handle the instant event, while the RepNotify variable handles the persistent state.

Below is the OnRep function called when the variable bChestOpened is updated.

Click for full view

This example solves the issue we are presented and demonstrates proper usage of Multicast funtions and RepNotify variables. The result is what one would expect to occur when opening the chest in a networked game.

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback