How to replicate UOject as a UProperty?

I’m using classes derived from UObject to replicate only data across server and client by marking a raw pointer to the class as UPROPERTY(Replicated) and then adding it to GetLifetimeReplicatedProps .

The UObject based class is instantiated at runtime inside an AActor using NewObject and assigned to the pointer.

but as you guessed it its not replicating to the client. I came across a few post mentioning how to replicate UObject independently but that is not what I want to do here, I want to replicate the UObject class as a variable in the actor class.

Any suggestions on this? Or should I switch to USTRUCT instead (which would mean losing the ability to pre-define the data)?

See at the bottom of this page, Advanced: Generic replication of Actor Subobjects.

Nice find.

but since its a wiki instead of official doc I wonder if its the proper way to do that or a hack/workaround?

I’ve implemented it. It works fine and is surprisingly straightforward.

If you wait for official docs on how to do things in UE4, you won’t get much done. :wink:

hey I’m not complaining, but I guess what you said is true.