AnimNotify not trigged on server side

Hi all,
I am trying to get an AnimNotify event to trigger on the server. I have a sword animation and need to detect for collision at some point during the animation. This works great when running both client+server in a single instance. When trying to extend this to work with multiple clients and a single server (either a dedicated server, or a client that acts as both the server and another client), I struggle.

My setup:

  • A character that consists of a normal skeletal mesh, which is hidden, that has a child that is retargeted and mimics the parent skeletal mesh. For both the skeletal meshes, I have set ‘Visibility Based Anim Tick Option’ to ‘Always tick and refresh bones’. This is the result of Unreal 5 Synty Studio Polygon Character Workflow - Animation Live Retarget - YouTube (5min video).
  • With multiple clients, I can see that the sword animation is correctly showing. Thus confirming replication works and the animation state is correctly shared.
  • When debugging the dedicated server character animation blueprint, I can see the state being set correctly. It enters the ‘Attack’ state, leaves it after approximately the animation duration. Thus confirming that the server also is using the correct animations.

Why do I need the AnimNotify?
I use an AnimNotifyState to start my hit check and end it at some point during the animation. Before I started with multiplayer, I was really happy with how well it works and how easy it is to add support for more attack animations.

Why do I need it to trigger on server side?
Because I’d like to do all hit detection on the server. Therefore, I am checking whether GetOwnerRole() == ENetRole::ROLE_Authority is true.

I found this post: Animation works on client, not on server... - #27 by Backov It looks like it explains exactly my situation, but its solution does not help for me. As it looks like a little bit of the code changed, I tried overriding TickCharacterPose in a custom UCharacterMovementComponent and calling SyntyMesh->TickPose(DeltaTime, true); manually. Next to this, I tried to call SyntyMesh->ConditionallyDispatchQueuedAnimEvents(); manually too, without luck. I can see this being called on the server though, making it harder to understand why it does not work.

I am using Unreal Engine 5.1, on Windows 11.
Thanks!
Sincerely,
Floris

The fact that I use a second sketal mesh is not the problem. I have recreated my player character using a single mesh (following the default third person setup) and the problem still occurs:

  • when I play the attack animation on my player, no AnimNotifyState is triggered on server side. It is triggered on client side.
  • when an AI (owned by the server, using AIController) plays the attack, AnimNotifyState is triggered on both server and client.
  • even Animation Blueprint transition AnimNotify events are not triggered on server side for the player character. Again, they work for the AI. During debugging, I can see that the server goes to the attack state and its duration gets reset (which should mean it should trigger the transition event).

This leaves me clueless. Is there no way to make AnimNotify work on the server when using a PlayerCharacter? Anyone has an idea what is going wrong here? Thank you so much…

Update: Even just using state events shows this problem.
image
image

Will print the following:
As listen server:

LogBlueprintUserMessages: [ABP_Manny_C_0] Server: Hello
LogBlueprintUserMessages: [ABP_Manny_C_0] Client 1: Hello

As client:

LogBlueprintUserMessages: [ABP_Manny_C_0] Client 1: Hello

Note, this is using a single standard skeletal mesh.

Turns out it is an Unreal Engine bug: UE-170093 Unreal Engine Issues and Bug Tracker (UE-170093)

After creating a brand new project based on the third person template, simply adding an AnimNotify to the jump animation and printing when it is triggered: it only works on the listen server… if other clients jump, it will be triggered on all clients, but not the server.

Hope this will be solved asap! This means multiplayer AnimNotify, whether in transitions, in animations or AnimNotifyStates are not working!

Until epic fix this, you can use the following console var as a workaround a.EnableQueuedAnimEventsOnServer 1

3 Likes