Download

Confused about Replication

Hi. I have a very simple scenario, when I try to sotre state on server and reuse it in clients.
I have a Blueprint actor which holds a variable “running”.
The root and the variable are set to replicate. Please see the blueprint below.
The issue is that the variable is never set. I always receive “false” on tick. What am I missing?

There could be many reasons but the most likely reason is that you are calling SetRunning from a Client that doesn’t have ownership of the Actor. You will know that is the problem if you inspect your output log and find


No owning connection for actor ...

It is also not necessary to use a SwitchHasAuthority after SetRunning since you flagged it as “Run On Server” so it will never run on a Remote Client.

I know you are testing things out but checking a variable on Event Tick is a bad idea as it will flood your log. Replicated variables can instead be set to RepNotify and you will get a perfect function call every time something happens to the variable that you can then print.

Here is a checklist:

Is the variable “Replicates” on the Actor set to True
Is the Actor Relevant (set the variable “Always Relevant” to true to override relevancy)
Is SetRunning called from a Client that isn’t the Owner of the Actor (check the output log). Solve by calling SetOwner on the Server to anything the Client owns like its PlayerController or Character