Why does send gameplay event trigger multiple times?

I am setting up abilities with the ability system. The one I am working on spawns a projectile which destroys on impact and does a “Send Gameplay Event to Actor” back to the ability/player. This works fine.

But the ability is spawned per instance as multiple projectiles can be shot rapidly (imagine a Mage fireball in World of Warcraft). The NEXT ability tends to “finish” immediately when triggered by the player, and I found this is due to the PREVIOUS ability having sent the Gameplay Event. If the player waits a second or so and then triggers the next ability this does not happen.

How do I get around this? Should I have some way to recognize WHICH ability instance sent the event? I have found a hacky workaround where the ability checks which ability the projectile sending the event belongs to but it seems off that this is not built in functionality and no one else is asking this question as far as I saw.

The ability code:

The projectile (simple sphere collider with projectile component):

Edit: Attached some pictures

Hi,

Would it be possible to add images about what exactly is happening? I am more of a visual person and it would help tremendously :slight_smile:

Done. Thank you.

Thanks for providing the images; very helpful :).
I will be working on reproducing this issue locally and seeing if anything stands out in terms of a solution. I hope to find something as soon as possible :smiley:

I have an answer, just having issues posting a comment with all the info :frowning:

Thank you for taking the time for such an elaborate answer, that was very helpful. I went with your suggested approach and it works wonderfully. Post as answer so I can accept!

Instead of waiting for the gameplay event within the ability that spawns the projectile, you can do one of two things:

  1. Instead of sending the gameplay event back to the player, and waiting for the event in the same ability that spawns the projectile, you can instead handle everything you want to do via the projectile itself.

When spawning your projectile, make sure that the instigator is your player:

Then within your projectile, you can still use the Hit Result and Impact Point for the OverlapSphereActors function and then use the AbilitySystemComponent from your Instigator to apply gameplay effects onto the returned actors from the overlap. Please see the following:

You just need to make sure to use the AbilitySystemComponent from each actor in the array as the target of the ApplyGameplayEffectToTarget; the Instigators’ AbilitySystemComponent is the primary target that applies the effect.

In my professional experience using GAS, whenever we spawn a projectile, or any other actor, we apply gameplay effects via this actor instead of calling back to the original gameplay ability via events; we found this was easier and more maintainable.

  1. You can grant the player a second ability that solely responds to the gameplay event that you want it to; in this case Abilities.FireBomb.ProjectileImpact. The ability would use the Ability Trigger for Gameplay Event using this tag:

350505-triggerevents.png

Then, you can use the Event ActivateAbilityFromEvent to respond to this trigger and it provides to you the target data you require:

350506-activateabilityfromevent.png

I hope this helps, and good luck.

Done :slight_smile: I am glad this helped and it worked for you.