Issues with replication and animations

I have a problem I can’t seem to resolve at the moment, perhaps someone can help me out? I started a project from scratch and followed the TPP tutorial series. Everything worked flawless thus far. I then watched the networking/replication tutorials and decided to replicate the melee attack I created based on the TPP game tutorials. This is were my problems started occurring. I’ve implemented authority switches, changed all vars to their correct(or so I assume)replication parameters. I’ve created a custom event to RPC the isPunching bool which calls the animation montage in the animation blueprint. So the animations should only be called by the server, not the client.

I’ve added a print that simply says “PUNCHING” to see if the string replicates correctly, which it does. The animation montage plays as expected locally on both client and server, but it still plays the animations only if the server calls the event and not when the client does. So it seems like something is lost somewhere between the animation blueprint and the character blueprint in which I call the print after my authority switch as that part seems to replicate but not the animation call?

Hmm, it seems like it could be related to the cast to mycharacter node which somehow won’t let the isPunching bool compile as replicated as it simply resets to not replicated when I hit compile.

first, print is replicated regardless, newer version has Server/Client prefix so you might want to check the result more carefully.

second, compile reset is normal when you have circular dependencies, which usually caused by CastTo nodes. it might be easy or hard to solve depending on what your blueprint dependencies looks like.

sorry i can’t give any solid guessing, but here is one, did you ever access animation blueprint directly in your character BP?

What do you mean by access the animation BP inside my character BP? It’s referenced through the animation in the mesh/animations defaults for the character and the custom event call is directed from the character BP to the animation BP.

for my experiment before, you always not directly call events in animation blueprint.
Instead, you set a variable to indicate that you are doing punch, and then in animation blueprint, use pawn owner in animation bp to cast and get the status, set a local variable to reflect that your are punching.
This way, in your pawn/character, you only require to be careful about if a state variable is replicated properly. While in animation bp, since it’s not replicated at all, just query the replicated pawn and do animation accordingly.
thus server only checks if you can punch, instead of hand holding the entire punch process. It is client that do the heavy/graphical things.

remove the animation event call in your character BP, you should then be able to compile.
work from there with my suggestion above.

You have obviously misunderstood me a great amount, perhaps I explained myself wrongly. I am already doing everything like you say, as we are shown through the tutorial series I mentioned in the original post. I have no animation functions inside the character BP, I am setting a replicated boolean isPunching and passing it to the animation BP.

1 Like

this is where i misunderstood(?), i thought you said as quoted. animation should not be controlled by server or client(player) directly, they should be pretty self contained, so animation bp gets all input by GetPawnOwner and then cast. if at any point your gamemode or controller/pawn bp is calling to run a montage, that’s wrong. animation bp should just do it’s work, mostly on client machine, with no knowledge if a control variable is replicated or not.

I have a video on youtube posted a while ago showing Owen doing jump jack on command. let me see if i can find in my old projects.

What I meant with custom RPC event was a new custom event in the animation BP that gets the value of the replicated isPunching boolean from the character BP and then plays the montage.

is this what you would like to do?

edit: oh, and at no point of my setup passing anything to animation bp.
my animation bp only get variables from GetPawnOwner.
here is how I do it, no special custom event in animation bp.


don’t mind about the cast fail orange line, it was just the animation bp itself and not even running.

That’s basically how I’m doing it, here’s a screen:
caf24dbb5b05d9e91b92df0ca81ed2bae60a6d0f.jpeg

like I said, you should not have the Punch event that “play” the montage, because UpdateAnimation event will just override your montage play request.
instead, you setup a state change in animation bp but let the state machine to blend it for you.

Oh okay, now I understand what you meant then.

Hello! Sorry for necroing this thread, but I’d like to ask if this still holds in Unreal Engine 5.

I’ve stored a reference to the animation blueprint in my character blueprint’s begin play (ignore the strange lines, I just moved it to fit all the nodes in frame).

Then, whenever I want to update a variable in the ABP that feeds to the state machine, I set it via an RPC.


I have tried everything, from client only, to server only, to server and multicast, to just multicast. All I get is either nothing on client, or an error on RPCs telling me that the ABP does not exist.

At this point, I’m beginning to question if maybe I should capitulate and have boilerplate RPC functions for every variable in my ABP and be done with it already.

You need to understand the execution pipeline.

Every Frame/Tick…
First, Process Character Class → Event Graph
Then, Process Animation Class → Event Graph
Then, Process Animation Class → Animation Graph


In your ABP get a reference to the Character Class. Then you can directly check the “Crouch Command” bool via Character Reference -> Get Crouch Command.

From there you can just set the ABP local var to the value returned.

What you’re doing know is essentially setting a past tense representation of “Crouching”. As soon as the ABP’s update fires (event graph) it’ll override what you just set in the character event graph.

Hello, thank you for your response. I really appreciate it.
I admit that I’ve been having quite a lot of trouble wrapping my head around how ABPs work.

Is there any way to avoid this being overwritten? I ask from a genuine desire to better understand how the engine works, please do not interpret my question as me doubting your answer or anything of the kind, it is most certainly not my intention.

The reason I ask is because performing a check every tick inside my ABP that fetches the value of my character’s crouch boolean just to then copy it to a duplicate variable within the ABP seems a little wasteful. Most of the time, the crouch command boolean will be in the same state as it was before, therefore we’d be fetching an entire class every tick just to update a variable without any changes.
It seems to me like it would be more efficient (particularly if it means not needing duplicate variables for the ABP to copy from on the character’s blueprint) to directly set variables in the ABP only when a change happens, then ensuring the ABP does not overwrite variables unless explicitly told to.

Of course, it occurs to me now from the way you described the execution pipeline that the ABP may exist in a volatile state, unable to retain the state of variables between ticks, which would indeed necessitate the need to overwrite data each tick. If that is the case, for whatever the reason, I can certainly comprehend why that approach would be most optimal.

Once more, I genuinely appreciate your response, finding information about how ABPs work (and why my approach does not seem to) has been much harder than I had anticipated, so receiving support and wisdom from my betters is something I am endlessly thankful for.

The default Animation BP class uses the mentioned structure. Open a new Third Person project and take a look. You’re creating a reference to the character class on initialization. It is then constantly being queried.

You can see here that it’s directly referencing the character class and character movement component… to set vars.

Additionally, CMC has its own bools for movement states.


A more flushed out ABP looks a bit more like…

Functions that execute in a set sequence, most of which are using “character class” and CMC values.


As a general rule you do not modify variables of a class, from another class.

For Char to Anim communication you set states etc in the character and reference those states in the anim class.

Once you start working with mesh bones you’ll see you need a reference to the character which owns the skeletal mesh. So, Character Ref → Mesh will be a common reference.

Hope this helps :smiley:

Thank you very much for your reply, this is indeed very insightful.