So I am trying to learn GAS and like the title says I’m trying to make an ability that fires off repeatedly when the input is held, but stops once released. Think of something like a full auto weapon, for example. I’ve managed to get the first part of things down, it repeatedly activates once I press the button, however I can’t figure out the stopping part. I’ve tried using the “Wait Input Release” node but it never registers when the input is released, which I suppose makes sense since I don’t really ever remember giving it an input to monitor to begin with (or even where I could do that).
I feel like I must be close to the solution, so perhaps another set of eyes/a second opinion is all I need.
Nowadays, the common practice is to activate abilities using tags, but that is not something that is built in the engine. You can see an example of that in the Lyra project, it requires a bit of code to set up. I have extended that behavior a bit as well to support setting the tag directly in the ability tags instead of relying on AbilitySets like in Lyra to set the input tag
However, if you want to use the older approach that can easily be implemented in BP, you can do it like so:
Create a new enum with all your ability inputs (optional, you can use plain ints if you want)
When giving the abilities, you can specify the input id, which you can get from the enum (using the literal enum node)
When setting up your input actions, you can now do AbilitySystemComponent->PressInputID and ReleaseInputID instead of try activate ability
That should correctly trigger ability activation if the ability is not active, or the WaitInputPressed task if the ability is already active, as well as WaitInputRelease
How would I do that though? The End Ability node is only available within the ability itself, and I don’t have a ref to it in the player since I’m activating by tag.
This worked! I’m hesitant to flag this as the solution in cast something else comes along that works better, but for the time being this does achieve what I’m looking for.
Oh yea, I guess it is protected. and couldn’t really even be cast to reliably. Sorry. I’ve never really used GAS. Unless you want to do some C++ code, Zeaf’s post sounds like the solution.
Also an added tip, timers are automatically stopped when abilities end (unless overridden in C++ or if AbilitySystem.ClearAbilityTimers is set to false)
Same with all AbilityTasks
But not AbilityAsync tasks or other latent actions, such as Delays