Network Replication from Client-Side
Hey there, I'm trying to get a Lightbulb toggle on a switch working on Client and Server Side of my Game. I've watched the Intro to Blueprint Network-Tutorial and decided to setup a RepNotify to let the client know when the Light is switched on. The script is working, but only from the ServerSide. So if I use the switch in my Server the Light is toggling on both Client and Server, when using the toggle on my Client however only the clients light is toggling. I've tried using a Custom Event "Run On Server" and then Multicast it to all other Clients, but that doesn't seem to work either. How can I tell the Client to Ask The Server to Switch the Light of every client connected?
I'll attach my blueprints and two screenshots showing the issue.
Thanks in advance Max
asked Sep 24 '14 at 03:24 PM in Blueprint Scripting
There are two main concepts within networking in unreal. The first one is variable replication, mainly changing a variable and replicating it always from the server to a given client. The second one is function replication, calling a server function from the client or calling a client function from the server, this is also called a RPC (Remote Procedure Call).
What you want to achieve is a mix of both, the client toggles the switch and has to call a server replication function to change a variable. The variable must then replicated to to all clients via replication and when the event happens on each client you have to update the switch accordingly. The client that calls the replication function could just update the light bulb on his box so that you simulate the behavior and it will look behave better in net work saturation.
Just as a note, make sure to replicate to all clients. The variable won't be replicated to the players that are hosted in the server itself though, there you have to update the bulb locally.
Hope I could help!
Follow this question
Once you sign in you will be able to subscribe for any updates here