Question about Secure Networking and Switch Has Authority

Hello, I am working on a multiplayer game and l was wondering what is the most secure way to communicate between the client and the server? My game is using the listen-server model.

Would this be the best way to communicate? Basically I’m forwarding the remote client “Runs on Server” event to the Authority “Multicast” event.

This is a broad topic that is hard to understand until you practise. Replication is the key here.
Listen server or dedicated / Doesn’t Matter. What you really mean is you intend to have an Authority Server (Which is the premise of UE4).

So! To try keep it simples:

A variable that needs to be protected from cheaters say, your health, should be controlled by the server.
In such case, you would make a Variable “Health” in your Character BP which is REPLICATED. I usually have mine set to Replicated /W notify so that I can fire certain events depending on their current health value.

But to start you need to set this value. Best practise is to make a function from the Event Begin Play which firstly has the Switch Has Authority Node. Then this would set Health to Max health value.

Now any damage modifiers are Server controlled anyway thus making this still work. You cant change that value. Anywhere you NEED to manually change their health? You would create a custom event in the event graph and set it to be a Run on Server event which is reliable. I often then put a switch has authority node, not necessary but it harms no one and just gives that little bit more security!

This would then change the value of health on the server and replicate down to clients.

Important to note that Actor BP’s can not call server events as actors are not quite replicated the same way on a level.

I strongly recommend these tutorials to start and then play around and practise:

Best of luck!

Yeah from what I understood that’s the best way to communicate datas from a client to all others

  • The server call a server RPC to pass the data
  • The server update himself and other clients whether using a replicated property or using a multicast event

Be careful with multicasting. Bare in mind the performance and network cost.
I think the best approach is to try it with as little to no replication as possible. Then add replication. Then add a multicast if it definitely needs it!

Why would a multicast call be more costly than a Replicated property ? I mean, the deep Engine code would be probably the same no ?

A multicast means an event/function that happens on the server will then be reproduced on all clients.

Replicated is just a variables state, for example in the tutorials I linked above? Lets say the chest has a Boolean value that is replicated. In the function it might for example say when this is opened set the Boolean to true.

Now the event that fires this? Let’s say it is non-replicated. The initial person entering the trigger for the chest to open sees it open as the function got called.

Next person however does not and cannot interact leaving it in a broken state to them. They see it as closed as the Boolean already states it is open and therefore cannot be opened again. But they never saw the chest open.

A multicast would make the chest open for all. While this is good behaviour on paper? If they cant see the chest? The multicast was wasted bandwidth and draw calls.

Some things you might not want to multicast at all and instead just run on server which replicates it back down anyway thus creating twice the traffic for the same result.

The tutorials in my original post explain this much better and simpler and definitely worth a watch before attempting any multiplayer game creation!

Oh yeah I forgot about relevancy :smiley: