Basic replication - help

So if i have a replicated variable, and I set a value on the the server, that value is sent across the network to be read by the client, is this correct ?

I have a replicated component, and I can not get the above behavior to function at all.

I have set the variable in the component to replicated, and always relevant, but any changes I make server side are not visible on the client. Where else can I look ?

Replication is a hard to explain subject in just few lines, but I remembered some good videos from Epic which covers the subject with good details:

older one: Replication | Live Training | Unreal Engine - YouTube

most recent one: Network Multiplayer Fundamentals | Live from HQ | Inside Unreal - YouTube

and this one about optimizations on server side: Networking in UE4: Server Optimizations | Live Training | Unreal Engine - YouTube

I hope those explains more and deeper than what you could get from these forums.

OK so I set up a simple test - I added a variable (boolean) to player state. Set it in a server side routine, read it on the client. The update is replicated to the client - all working as I thought.

Now I do the same test but with a struct: The update is simply not replicated to the client, and yet I believe that structs ARE supposed to replicate !!

UNREAL GURUs what have I missed here ?

also did the same with a replicated actor, so set a variable in player state to type “rep_actor” which is set to replicate and is always relevant, also the variable is set to replicate also. Spawn an actor on the server and assign that actor to the variable in player state on the server. That actor isn’t replicated on the client.

Is it not supposed to ?

Just 2 thoughts coming into my mind:
For the components, there’s an extra flag “Component Replicates” in the details section - I assume that you did check that box when you say, you have a replicated component. I did fall into that recently…
What do you mean exactly by struct? At least for Map and Set structures, these are not replicated by design.

Just in case your Struct is in C++: check, that the USTRUCT members you want to be replicated have UPROPERTY() set. This might cause your struct data not being replicated.

Herb, I am embarrassed to say that it was the component replicates.

Glad to hear, that my first suggestion did help you to solve your issues.

1 Like