Working way to replicate 'Drag-To-Open' Door on Listen Server?

Currently attempting to replicate door rotation and can get it to work locally, however I’m struggling to replicate from client to server/other clients.

What i have so far is as follows.
Character Interacts with door > Sends interface message with mouse values > Door rotates to values provided.

I’ve tried just about every combination of Event replication type and seriously cannot get it to work.

How are you sending the rotation value from client to server?

Remember that you cannot call a Server RPC on an actor you do not ‘own’. And generally the only actors you own are your player controller and pawn.

You will need to route your door rotation RPC from the client through an RPC on your pawn, and on the server(authority) side, you can set it on the door and it can replicate back down to clients. Don’t use RPC to send it back to clients, this is state, and should be replicated.

1 Like

So if I’m understanding correctly, it should be as follows:
Client sends the axis values to the door, door sets rotation.
Client sends axis values to Server, server sets actor’s (door) rotation.

↓↓ Ignore the rest if the above is in the correct direction, I will implement the above and try again once I’m able. Below is just to give insight as to how I’m currently doing it. ↓↓

As of right now the exact method I’m using is as follows:
If LMB is pushed while over an actor that implements the ‘Door Interface’ we store that actor in our character
tick event goes to a sequenced event that will update the door with our mouse X axis
which in turn attempts to call a server event that then calls a multicast setting the rotation.

If you are calling a server RPC on the door actor that’s where it is getting dropped.

Routing it through an actor you own means basically making an RPC on the character called like UpdateDoorRotation that takes the door reference and the rotation value. Then on the server side you can set that value on the door since it will then be on the authority side. The function is basically a middle man just to get to the server with an actor you own.

Once you do that you will want to communicate the door rotation to be replicated back down to clients, not a multicast RPC. Couple reasons for this

  • the door rotation is state. And state should always use replicated variables. If a client joins your game late, they will get accurate values for your door rotations if they are replicated. The doors will all be wrong if you used RPC because that client wasn’t there to get the RPCs.
  • RPC needlessly (in this case) circumvents the functionality of replication. If I manipulate a door on the other side of the map, it could be out of network relevancy range and not need to update clients not close enough to see it, until they move closer. An RPC, especially a multicast RPC is something to be avoided most of the time.

RPC should be used for one off events that can happen, but if they’re to result in anything with any degree of persistence, that part needs to be a replicated variable from server to client.

Hope that helps.

You helped me accomplish my task!
Door works appropriately across clients/servers. Also works even if someone is past the relevancy range. Thank you!