Hi, I’m currently working on a bank vault opening functionality. I’ve set replication on the custom event to multicast, but the door will only open for everyone in case it is executed on the server, how can I make it so if I a client/player opens the door, it is replicated for everyone?
My blueprint:
Make a second customevent set to Execute on server. Make that be called when pressing 0. Inside that event, call the multicast from there.
Hi, thank you for the answer, did you mean like this?:
Because right now all this did was restrict it so only the server could open the door at all. Sorry for the inconvenience.
It’s important to note that Execute on Server custom events are only executed on the server if the calling client owns the actor. Some actors that are automatically owned by the player: pawns and player controllers. The Level blueprint for example is not. Execute on Server events are still the way to go, however the trick is to gather the user input client-side and then “go server-side” as soon as possible.
What I do for interaction with the environment is:
- Client-side when a Use key is pressed, I trace for an actor to potentially interact with. If it is found, I call an “Execute on Server” custom event InteractWith(Actor). This custom event is in my pawn class and this setup works because a player pawn is owned by the player’s client.
- When calling InteractWith(Actor) is called, execution happens server-side, so all is well.
Thank you for answer, but as you probably can tell I’m new to this.
Could you possibly show an example fit for my needs?
Thanks