Animation replication is not working

Hi I am making a game based off of the multiplayer ue4 youtube tutorial series, My character animations are not replicating correctly i have tried many of the methods on youtube and based on my own understanding tried some things, nothing has worked. Screen shot 6 shows the replication script as well as the settings for my character’s replication, Screen shot 7 shows the event graph of my anim blueprint screenshot 8 shows the condition for the animation to be played.
I would love if someone could look through the code and help me find this issue.

1 Like

It looks like you flipped the names on your RPCs, and while that’s confusing, it isn’t what’s breaking your code.

“Switch has Authority” is a node that checks to see if the object running the code is on the server or on the client. In most multiplayer games, the server must have authority to prevent cheating. What that means is that the game code should run on the server and the client should have no say whether the code works or not. All the client does is sends requests to the server, then the server says “hey, can he do that or is there a restriction that prevents it?” and if it’s ok, the server does the code and the player gets the update after it runs on the server.

“Run on Server” sends the command to the server from the client and runs it.

“Multicast” will execute only from the server, then send it to the clients so that it runs on their machines.

So, when the server presses Right Mouse, “Cli_Dash” runs. “Cli_Dash” is a multicast, but won’t execute code on the clients because the “Switch has Authority” node will only let that code run on the server. There’s no point in making it multicast if it can’t run on clients as well. The server will set the replicated Dash boolean to on, then after a delay, turn it back off.

When the client presses Right Mouse, “SrvDashCall” runs. The “Switch has Authority” node doesn’t do anything here, since we already know this RPC only happens on the server anyway. Then “Cli_Dash” runs and should execute on the server, in spite of the issues outlined in the prior paragraph.

The boolean should be updating correctly. Your state machine may have some kind of conflict going a different way.

Try this. On tick, use a “Switch has Authority” node and on Remote, use a Print String node set to last 0.5 seconds. Get the Dash boolean variable and plug it into the text node, which should automatically convert it to “true” or false". When you test the game, it’ll spam in the corner but when you press the button, the client should read “true” and you can figure out if the problem is in the networking or not.

[Net Update Frequency]
From the other post. “Min Net Update Frequency” determines how often your character updates. “Min Net Update Frequency” is how infrequent the character will update if the character has been idle. I’d recommend making sure that “Min Net Update Frequency” is set to the same as the normal “Net Update Frequency”, which is set to 100.

@Ray_Unreal
I am sorry for the late reply i checked and edited my blueprints. i brought up the “Min Net Update Frequency” to 100 and made the multicast event fire from the anim blueprint. The animation is seen on the server’s screen when executed from the client but not seen on the client’s screen when executed on the server. ScreenShot-11 shows the Main Character blueprint ScreenShot-10 shows the Event graph in the anim blueprint.

Dude. Why did you up and change everything? Why did you move the code to the animation blueprint? That wasn’t even a problem.

Print String is the best problem solving tool you have. I asked you to setup code to see if the bool was changing on the client or not, then you can figure out if there is a logic problem in your animator or if the variable isn’t replicating correctly. I’ve spent enough time as it is trying to help and typing up a giant thing to just have you ignore what I said.

@Ray_Unreal i am sincerly sorry, i must’ve understood ure original reply wrong(the part about the state machine i misunderstood that) also i forgot to mention i did do the event tick print string thing, the boolean changed to true but it alternated as in it printed:( client 1:true, client1: false, client1:true, client1: false) repeatedly until 1.1 seconds finshed(i did do this before changing to the anim blueprint i just assumed that result was fine but if it wasnt i am sorry i did not get back to u about that sooner). I moved the event to the anim graph out of curiosty to see what happened and it ended up working in a way that the the server could see all changes in the boolean(as in it could see the client’s animation as well as it’s own) but the client could not as if the replication half worked. I also did take out the uneeded switch on authorities that u mentioned and brought the “min net frequency update” up to 100

First off, some general points you should keep in mind:

-If you want the clients to see what the server is doing, the appropriate variables need to be replicated (variables ONLY replicate from Server to Client, not the other way around). One way to do this is what you are trying to do, which is to use a replicated variable that is called on tick from the Anim BP. What you are missing is that you need to set that variable on the server if the clients are calling the code. In other words, the server should simply set the “Dashing” bool, but the clients should run a custom event running on the server, which in turns run a multicast event, which then sets the “Dashing” bool. Alternatively, you can try the method I’m suggesting below using interface calls if you don’t need it set on tick.

-If you want the server to see what clients are doing, they need to run the code you want replicated on the server.

-If you want clients to see what other clients are doing, you need to get that code to run on all the connected clients (this is what a multicast would accomplish).

So for example, if all you’re needing to do is replicate an animation that’s triggered in your Anim BP by a boolean, and you don’t need that boolean checked on tick, you could try the following:

  1. Create an interface for your Animation Blueprint.
  2. Create a function in the interface to set the variable you want to replicate (i.e. “Dashing”).
  3. Call that function you just created as an event in your Animation BP and use it to set your variable.
  4. In your Character Blueprint, set up a custom event running on the server which in turn runs a custom event running a multicast which sets the variable in the Anim BP using the interface call.
  5. Finally, use a Switch Has Authority to check who’s running the code. If it’s the server (the authority), you just need to call the multicast event. If it’s the client, you need to get the server to run that multicast for you, so call the server event.

I’ve attached screenshots of a working example I’m using in my own project below, where I’m setting an “Is Taking Cover” variable in my Anim BP so the taking cover animation is replicated to everyone. If you’re not interested in this approach, like I said in the first paragraph, it’s very simple to just replicate the variable and set it in your Anim BP tick event. Just make sure clients are setting that variable on the server.

AnimBP Interface:

Interface call in Anim BP:

272533-animbpinterfacecall.png

Custom Events in Player Character:

272534-customevents.png

Switch Has Authority check:

@Ray_Unreal i am sorry i ended up misunderstanding the part about the replication and state machines i also forgot to mention i did do the tick printstring method and got the boolean setting to true and alternating between true and false for 1.1 secs (the delay for which it is true) ure previous replay was extremly useful for me understanding replication so thankyou for your help

@Drgy55
Thankyou this method worked this has been annoying me for a week and it is finally solved

Thanks! A slight tweak to your suggestion worked for my issue. I was trying to play an animation that all clients would see when a player joined the server. Very grateful for your suggestion. Here it is if anyone is trying to figure it out still!

Replicated Character Start Animations