I have a multiplayer action game using the Gameplay Ability System Plugin. The whole system has been working great with damage being done, attributes being modified and animations being play all replicating correctly for the past few weeks.
However a few days ago I added an attack that would give energy back to the owner on the hit frame of the animation. This is implemented by applying a Gameplay Effect to Owner, which simply adds a scaled float to the attribute (Energy += 20) and looks like this:
(There is nothing else active within this GE, no gameplay cues or anything else, it just adds +20 energy)
However depending on where I apply this I get different outcomes. This version works correctly:
Server+Client both think this player gets 20 energy and everything works. But if I call the exact same thing from inside the event call-back like so:
The animation plays correctly as before, the event is fired but then on the client (and only the client) the energy gain is applied twice and the client now thinks it has 40 energy not 20. The GE isn’t trigger twice - it’s only applied once on the client, but then the energy update from the server is replicated over and doubles the value. When using the showdebug gameplayabilitysystem
command I can see that on the client, it thinks the GE’s are still in effect despite them being instant. After using the the Strike ability a number of times it looks like this:
The client thinks it has 220 energy (compared to the base which is 40 which is what the server correctly thinks we have) because of these zombie GE’s that aren’t ever removed. And I cannot figure out why they stick around when called from inside the event call-back. When I do damage and apply GE’s to targets from within the exact same event it all works. But somehow applying an instant GE to owner inside the event call-back creates these weird zombie effects that continually mess up the local value on the client.
If I set the Net Execution Policy
to “Server Only” on the Gameplay Ability, these are never generated on the client and it works (although that obviously breaks the animations etc). But it shows the issues has something to do with local prediction not clearing GE’s applied from inside Ability Task events … but that’s as far as I can figure out.
Any help would be great - this is driving me nuts haha!