Server vs Client. Client will not play animation but server does (on action mapping button press)

I’m trying to get a character to play an animation when q is pressed. I have an action mapping event in the character that calls a multicast function in the game mode. The function sets a Boolean to true called PlayQAnem (which is used by the animation blueprint to play the correct animation). The function then activates the particle system on the character’s weapon (as each function is character specific I do not need a player controller to know what weapon to activate, as all the character’s weapons are different).

Works fine when the server presses q, client and server both see the animation played and the particle effect, however, when the client pressed Q, nothing happens, at all, the character can still move and turn ect. I am fairly certain my functions and variables are all replicated and am running out of ideas.

I’m happy to post screenshots of the blueprint if you want, I just typed it first to see if anyone knew what was going wrong right of the bat. Thank you in advance!

1 Like

It’s simply because clients has no authority on replicated things. The server has the authority. So here is the way to go:

  • Player press Q on the client side
  • Client call a server RPC function to tell him “Hey, I pressed Q, please set the boolean to true”
  • The server set the boolean to true
  • The boolean is replicated over the network (see my second part bellow to know how)
  • The client now has the boolean set to true as well
  • Everyone is syncronized now :slight_smile:

The “'second part”: To go further, there are to way to replicate things from the server to the clients:

  1. Use the replication property of the variable and let UE4 take care of it. You can use a RepNotify to know when the client recieve the freshly updated variable.
  2. Use clients RPC. The server will call theses RPCs to set the variable on clients side. This is more like a manual replication :slight_smile:

I hope I was clear. I suggest your look at this A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums :slight_smile:

Good luck.

You wrote a great comment, that’s exactly what I am looking for.
My problem that I am working on VR and I have 3D widgets that I added to the game
I use a BP class to add them and write code. but because these blueprints are separated I can’t put them inside the BP of the character .
They only executed in the server and the client can only see them without the action that made by server.
For example, at on of these widget I add web browser, when the server open something or hide the widget, the client doesn’t any of these changes.