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.

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:

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.