How can client talk to server?
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.
asked Feb 05 '16 at 02:12 AM in Using UE4
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.
answered Feb 05 '16 at 02:31 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here