Networking, opening a "door" through all clients

I have a player pawn, when I press a button through has athourity, it sends a raytrace out and when it hits the door actor I calls a custom event in the door actor that do stuff, (the custom event in the door actor has executes on all), but it only works when the server calls it? how do I make it work for all clients?

I just finished working on my network door, so I can tell you how I did it. I have a BP called Interactive Door that is inherited from my Interactive Object BP. In the Interactive Door object I have a custom event called “Interact”. This even checks for Authority, and then flips the ClosedOrOpen boolean value. ClosedOrOpen is a replicated var with Rep Notify. In the same BP there is a rep notify function called OnRep_ClosedOrOpen that checks to see the value of ClosedOrOpen and rotates the door to the closed or open position accordingly.

Back in the player controller (you could also put it in the character BP), when the character presses the E key to interact with the door I have the client call a Run on Server / Reliable custom event called “Server_InteractWithdoor”. This event on the server side calls the “Interact” event on the door that is in front of the player. Then the code I mentioned in the first paragraph replicates that to all players and they all see the door open as well as the door being open on the server for collision purposes.

If you have any questions, let me know.

thanks for answering me! :smiley: but probably not understanding you very well, But what I have done, is in my character BP I cast to the door PB when I hit something with raytrace by channel, and then run a custom event that has run on server (reliable), then that one runs interact from the door BP, but where should I turn the OnRep_ClosedOrOpen function and how on earth do I make it a rep notify? and also where do I set the closed or Open? var that has RepNotify checked?

A screenshot should help. First notice on the left side there is a variable named ClosedOrOpen. Then in the top right corner notice it is set to RepNotify. Setting that automatically creates a function called OnRep_ClosedOrOpen. You can see that function in the center. This is the code that runs on each networked client when the value of ClosedOrOpen changes on the server. This function is responsible for moving the door to the open or closed position in the world.

okay, cool! the more you know! but should I in the Interact event after switch has authority use a flip flop to toggle the var ClosedOrOpen?
sry for not understanding everything! :confused:

Yes, in the interact event on the server side use a flip flop to change the value of ClosedOrOpen. Then the rep notify will take care of the rest on the clients.

It works tho the client can’t open the door, only the server version?

because the client doesn’t have authority?

In the player controller or the character BP when the open door key is pressed you have to call a server event on the player controller or character BP that then calls the interact event on the door on the server side.

yes! that was It! after I press the key I run a custom event that runs on server then that custom event runs the raytrace and stuff!
Thanks so much for helping! :smiley:

Yep! Glad you got it working. Be sure to mark the question as resolved so other people with the same issue can find the solution.

sry for not being the brightest thing in this world! xD, but do I just add resolved to the title because otherwise I can’t find anything to mark this question as resolved?

Just click the circle with a check mark in it to the left of my first answer to accept that answer as the solution.