[Solved] Timed GameplayAbility

Hey folks,

I’m just trying to get a handle on how the GameplayAbility system works and was wondering if I could get a few pointers (I know it’s in a beta state at the moment, but the sooner I figure this stuff out the better).

So I have an ACharacter class with a UAbilitySystemComponent, and have all of the input mapping set up. With a simple blueprint (derived from UGameplayAbility) I successfully tested printing out a string when the ability is triggered.

So what I’d like to do next is give the player a speed boost for a limited time, say 5 seconds… but I’m not sure about the best way to approach this from C++. I’ve created a ‘SpeedIncrease’ class derived from UGameplayAbility, and am overriding things like CanActivateAbility, CheckCost, ActivateAbility etc, so it’s pretty easy to tell when the ability needs to trigger (and whether the player has enough ‘action points’ to trigger said ability).

But what should I be using to implement the 5 second speed boost? Is that what GameplayEffects are designed to handle? The UGameplayAbility doesn’t seem to ‘tick’ so it’s probably not the best place to keep a timer :slight_smile:

Thanks for the advice!

Can’t you just call a timer to disable the speed boost whenever you call the ability? It doesn’t have to be in tick, just wherever you call it.
So something like this

  • Do speed ability
  • Set timer to disable ability after 5 seconds

I never knew such a convenient plugin existed lol. I wish I knew this a few weeks ago before I designed my own ability system.

Hey Ninja_K,

So you mean something along the lines of (in UGameplayAbility::ActivateAbility):

GetWorldTimerManager().SetTimer( SomeKindOfTimerHandler, this, &UGameplayAbility::TimerExpired, 5.0f, false);

I could definitely go that route, just wondering if it’s the best approach or whether there’s some part of the ability system I don’t know about that’s built to handle this case :slight_smile:

I’d use the WaitDelay ability task since its designed to be used in abilities and is stopped when the ability is cancelled I think. When activated, call the static function in AbilityTask_WaitDelay with the parameters you want, bind the completion delegate on the instance it returns, and call ReadyForActivation on it.

Hey Acren, exactly what I was looking for - thanks!