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?
asked Nov 26 '16 at 03:05 PM in Blueprint Scripting
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.
answered Nov 26 '16 at 03:51 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here