a_najafi
(a_najafi)
1
I am trying to replicate a UObject from server to clients but have not been successful
I Have tried this approach but instead of playercontroller it’s gamestate:
https://forums.unrealengine.com/t/problem-with-uobject-replicaiton/412179
It would really help if someone could provide a working example snippet so I can understand what I am missing.
a_najafi
(a_najafi)
2
Ok so I found out what the problem was
first you have to do everything done in this post
https://forums.unrealengine.com/t/problem-with-uobject-replicaiton/412179
key takeaways:
virtual bool ReplicateSubobjects(class UActorChannel *Channel, class FOutBunch *Bunch, FReplicationFlags *RepFlags) override;
implement this function on the actor or actor component that the uobject is a suboject of
uobjects have to be replicated through an actor channel
virtual bool IsSupportedForNetworking() const override
{
return true;
}
than you have to implement this function and return true on the UObject that you want to be replicated
the final missing piece is this:
when creating the uobject you want to be replicated you have to set this flag RF_Public in the NewObject<>() function
this is not mentioned anywhere and I just tested the flags out of frustration.
2 Likes