Problems With Replication and Animations

  Problems With Replication and Animations

Author: Sean Jamelarin
Posted on 8/31/23

    The problem:
During this week of development, I ran into a problem implementing attack animations for the melee units; on the client's side of the game, animations were not working. If left unattended, clients would be left oblivious to unit combat, and would be slower to pick up nuances between units (ranged, magic, melee, etc.). As a result, a client's gaming experience would suffer greatly.

    The Solution:
I originally believed that a replicating function inside the Animation Blueprint would do the trick, calling the function to play an animation on a unit's client-side and server-side incarnation. This did not work, for reasons I am still unsure of. However, wrapping the call of the function itself in a replicating function worked - the best guess that I could hazard was that Behavior trees only work on the server; this matters because one of the tasks in the behavior tree triggers the attack animation. If behavior trees worked locally, the same unit would trigger the attacking code twice, once for server, and another time for client.

Here's a brief overview of work done:
    1. Created AnimInstance child class "ThirdPersonAnimInstance" that Animation Blueprint could                     reparent to
    2. Create replicating function inside ThirdPersonAnimInstance that plays animation.
    3. Moved function into the Base Unit superclass (Every unit draws from this class.)



TODO:
As of right now, I'm acquiring assets for the ranged dwarf unit. I looked to Paragon once more for "inspiration" and decided that a steampunk gunslinging dwarf was the right move. I'll have to start branching out different animation blueprints for different units, and different attacking behaviors as well.
Thankfully, we made the attacking behavior for the melee unit pretty modular; knock on wood, this should be a straightforward week.

P.S I just updated this post with a video, and as you can see, there is an attacking bug that allows units to attack cancel!? To squash it as a bug or leave it as a feature...

Comments

Popular Posts