UObject Replication

So according to this:

UProperties in UObject are automatically replicated.

But from talk on IRC I learned that they are not automatically replicated.

My questions is, what is the deal ? They are replicated or they are not.
If they are not, why replication doesn’t work by default with UObjects ?

I really liked my things implemented with UObjects, because creating them is much more convinient than Actors, though implementing replication from more or less scaratch looks daunting honestly, and I’m thinking about reimplementing everything using Actors.

I’ve been trying to get UObject replication working for a few days.

It seems basic types such as floats replicate, but a pointer to another UObject doesn’t, which is what I’m trying to do :frowning:

(Even with UPROPERTY(Replicated) and it set in getLifetimeReplicatedProps)

The first class in the UObject class hierarchy that implements replication is AActor. All game relevant objects that you wish to be shared between server and clients have to be Actors.

UObject is the most basic class in the Engine’s object system. You can think of it as ‘object’ in C# and Java. A game can have tens of thousands of UObject instances at any given time, many of which are not even relevant to the game. Imagine what would happen if they were all replicated! Hence it is the purpose of AActor to implement game relevant classes that can be replicated.

You said you like UObjects because they are easier to create. Are you perhaps using them simply to transfer data? In that case you may want to consider UStruct properties on your Actors.

If you are using the UObjects to replicate or share behavior, then you may want to consider function replication on your Actor instead.

If you are looking for a way to share data or behavior between different actor classes, or if you want to compartmentalize it to better structure your code, you may also consider Replicated Actor Components.

Thanks.
I’m actually using object, to not just only transfer data, but also to manipulate it in Blueprints. Like apply something at interval, or Cause X when Actor Y is in State Z. Exact behavior is defined using Blueprints.

I rethinked it a bit, and for that matter I don’t really need to replicate those Objects. Maybe one or two properties from them (like the remaining duration in seconds), I only need to replicate the final result that is on Actor (like slower movement of Actor).

I guess I just doesn’t know enough about replication. I have one question though. How do I make sure then, that Object (or Blueprint derived from that Object) is only run on server or other machine with authority ?

Yes, you should only replicate the bare minimum and only when it is needed. If only one or two properties are relevant, you can let the Actor class manage those values.

As for running Blueprints only on client or server, that would be a separate AnswerHub question. Doing a Quick Search reveals that there are already several topics and articles that may be helpful.

I’m trying to replicate a somewhat complex data structure on a Component,

i.e the component has 2 ObjectA’s, and a TArray of ObjectB’s

ObjectA has a TArray of ObjectC’s and an Object D

ObjectB may have an Object E

Everything is pretty static. Apart from basic types, references to Object D and E are the only thing that can change over the lifetime of the component.

I thought I could just implement all of these as UObjects, (rather than AActors as they don’t have a world position or components or anything) and selectively replicate the properties that I needed, but what you’re saying goes against this.

How would you recommend doing something like this?

Thanks.

see here about how to replicate an UObject derivative type property: