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
toAlways 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.
Any suggestions are welcome, I am a bit stuck… In case there is another solution to this problem that might be better (e.g. not using AnimNotifies), please let me know: there’s still a lot for me to learn.
Thank you!
Sincerely,
Floris