Okay, so I have a door and 2 players. How can I make it so that if one client press the f key the door opens for both players?
I’ve managed to make it work for the server; if a player is also the server he can open the door and the other player which is only a client sees the door open. But I can’t figure out how can a player that is strickly client can open a door for both players with a keypress.
Thanks in advance for any help.
Hi GuillaumeCote,
Asuming that you are working on blueprints, and you have a BP_Door blueprint, for example, you need somethings:
Inside your BP_Door:
1 - Create a OnRep_ variable called IsOpen, for example.
2 - Create a Blueprint Function called OpenDoor, for example, with the logic to open the door (using a animation or a Timeline)
3 - Create a RunOnServer Event called ServerOpenDoor, for example, inside this event you will put in true the IsOpen var and call the OpenDoor function.
4 - Now implemement the OnRep_IsOpen function and here just call the OpenDoor function.
So, when the character press the F key, you need to get the reference of the BP_Door and call the ServerOpenDoor Event.
Doing this, the server will open the door and replicate to the remote clients the IsOpen var, when IsOpen var is replicated to the remote clients the OnRep_IsOpen is called and the OpenDoor will be called also.
Best regards
… ahh one last thing, you need to put in true the Replicate property in your BP_Door to allow BP_Door actor to call RPC functions and replicate vars.