Replicating objects?

  • Actor component in custom player state.
  • Your GUI reads from the Player State AC.
  • Adding/Dropping etc would be an RPC to Server to validate action, then update the Player State for the character.
  • On successful update the server calls an update event on the owning client. Event refreshes inventory locally.
  • GUI Refreshes.
1 Like

“Adding/Dropping etc would be an RPC to Server to validate action”

How can you return back a status code from an event (RPC call) ?

The server would call an event on the client (player controller). That event queries the server for the updated info.

When you pickup/drop you’re telling the server “This controller” is doing X. Server does X, updates the auth state of the inventory in Player State AC. Then it tells the client (controller) to request the updated info. Hence Server get controller → as controller : call event update inventory.


“The server would call an event on the client (player controller). That event queries the server for the updated info.”
Why would the server tell the client to contact the server ?
How can the event (on the server) actually return the updated info - events can’t return info.

Replicated Objects can be passed to clients as a pointer (UObject*).
The server has a controller, but proxy clients do not.
The client has a HUD to draw item info, but the server does not.

So the client will request an item update on the server, then the server simply returns the result event to the client so it has a chance to update the UI.


Uobjects aren’t by default replicated.

The issues I am having are with a my inventory, I have implemented my inventory as a component that is held in the player state, the inventory component is set to replicate.

I think what you are suggesting is:

Mark the inventory component as needing replication - I have done this.
Make all your updates on the server - I have done this
Your client then reads its client side-version of the the replicated inventory - I have done this

The problem I am now having is it takes a while (maybe .3 of a second) for the inventory to replicate, so there is a window of opportunity while the client has out of date information. How do I know if the object on the client is in sync with the server ? Can I somehow force that synchronization ?

Let me know if I have understood your suggestion correctly.


No. I meant to say that c++ programmers can make UObjects* replicate from a parent Actor or Component, if they want to.

1 Like


Sorry not correcting you, just trying to avoid confusion - my game items are all actors - which do replicate.

Any thoughts on the synchronisation issue I am seeing ?


Replication only happens when some property changes.
Some people use a boolean flag and “flip it” false/true to force OnRep_ methods to fire when nothing has changed, but they need the function to be called.

Replication is happening - just not instantly from what I can tell. There looks like a window of opportunity where the client can read a value between the server setting it and the client receiving the update.

Is what I am describing possible ? is there away to avoid this ?

This is why you should tell the Client to update things from an Event on Client that is broadcasted by the Server when the inventory change is done, to update UI, timers, etc.

You can’t expect neither control which frame the replication is going to happen.
But you can tell the server to broadcast an Event into clients.
Reading the values from the client regardless of Server result will drive into bad behavior…

So… I should be updating on the server, that update then fires an event to the clients, and the clients can then perform the necessary action. Would that be safe ?

I have it working now thanks