Actor replicates from server to client, but not the inverse

Sorry if this is covered already somewhere, I dug through lots of docs, tutorials, and other forum posts and was unable to find a solution to this.

Basically I have a sliding door where you interact with it with a button press and it, via a Timeline, updates the X position of the door.

As expected, the door updates on both the Server and Client when called from the Server, but does not do the inverse. Maybe this makes sense because the Switch Has Authority does nothing for the Remote pin, but I’m not sure what to even do? How would I force a call from the Client to the Server to call the same event/function?

  • The root actor for the BP is set to Replicates
  • The StaticMeshComponent for the door itself is set to Replicates
  • The OnInteract Event is set to Replicate on Server.

Thanks!

All actors are owned/controlled by the server, except for the player controllers, which are controlled by each player client.
You can only replicate “to” server from the “owning client,” which ends up being the player controller.

So, you have two options here:

  1. Funnel messages from the door through the player controller so it can call “run on server” and forward the message back to the server object.
  2. Replicate the fact that the user is interacting with the object in the player controller, and detect it server side in the door.

I highly recommend option 2. If you need faster response on the client, you can “simulate ahead” until you get the message from the server, but syncing up this state is more work and only worth it for very low-latency situations like weapons and vehicles.

2 Likes