Hello all, please help me find solution for my multiplayer game. I faced with problem replication attack animation for client. How it work: when my AI see player he is moving towards him and play 3 animations attack, on hit event in animation player get damage. I config hit event multicast, and animation too, but players get double damage, because animation play on server and on client, if I config this action in server player get norm damage but doesn’t see animation. I understand what i need make this on server and replicate in like variable on client side, I already did this with set functioanlity, i create bool variable run event on server and replication this in animation BP, but for attack animation I don’t understen how it do.
Hello!
First. Animation runs on clients only Animation is always replicated and runned locally, server does not play any animation since he does not have animation, server just getting updates from skeletal mesh and updating bone loc / rot if configured.
So what you should do and i assume you check on server when AI can perform attack.
- When your AI is able to perform attack you should play Animations with net multicast event on all clients.
- In this time your trace tests should be done on server, because if that is animation driven (i mean animnotify will call trace test on server) that will be called from each client.
- If trace on server passed and AI should do Damage, apply damage only on server since in multiplayer games always server has authorative rights.
- profit
If you really want animnotify driven Trace tests, because you want sync damage apply with animation is also possible, just need more few test…
So first:
- As you started if AI is able to start attack, call a multicast event on all client, just to play attack animation
- Whenever your animation send animnotify and you do TRACE tests CHECK if target pawn / actor is locally controlled… If not do nothing… If yes…
- If pawn locally controlled call a Server Event and apply damage
Of course you can do the whole trace event on server, because testing on clients is not really hackproof…
but for start it will be good enough…
Hope this helps
Cheers
Hello AmphDev, Thunk for try help me, but look on my graph, I send multiast event for animation, and it work incorrect: players get double damage.
About Hit evet I can not use in server because for calculate damage I use map values, and they do not support replication, I use multicast for it and client apply damage on hit event.
You was right: Whenever your animation send animnotify and you do TRACE tests CHECK if target pawn / actor is locally controlled… If not do nothing… If yes…
AmphDev Thank you!
you are welcome