Download

Replicated UObject pointer doesn't replicate when values change

Hello.

So whenever I change a value in my replicated UObject pointer, it doesn’t replicate.
Replication only happens when the pointer itself changes, which is really inconvenient.

Just to make it easier to understand, let’s say my “UStat* Stat” has a value called “float StatAmount”.
When I change StatAmount, it doesn’t replicate.
When I change Stat (the pointer itself), it replicates.

Is there any way to force its replication?

UObjects doesn’t implement replication stuff, have no roles etc.

I’m using the owning actor’s channel to replicate things, manually. eg,
GetReplicationComponent()->ServerAudioPacket_SendRPC(AudioPacket);

In this case i’m asking the actor’s component to make it happen, but you can use an actor too.

You replicate values per UObject so you need to add replication to your float in UStat. The pointer is also replicated as a value(networked pointer).

I have done that though, but it still doesn’t trigger the “Stat” UObject to replicate.

The way my UI is done is whenever Stat for example gets replicated, in its OnRep function I call a delegate which my UI has bound.
Then my UI updates it’s text etc to match the new stats.

So how would I make changing “StatAmount” trigger “OnRep_Stat”? :>

I am not really that great at explaining stuff, so please bear with me.
Just ask if I make something too confusing.

EDIT: I just made a delegate, and bound it when the object was created. Now I just execute it whenever my value is replicated(on OnRep).
I’m not sure this is a complete solution, but it works for now.