Adding Cooldowns to Abilities with the gameplay ability system in 5.3

So after searching the documentation, tutorials, info on the web, I couldn’t find a clear way to add cooldowns to abilities. Often, stuff would be outdated, where some parts of the things to do were not there anymore in blueprints etc.

So I did a bit of trial and error, and finally achieved it and it’s finally quite simple. I’m writing this down for anyone else who can’t figure it out since I find the documentation on it is lacking.

First and foremost, you need an ability Blueprint. Whichever way it works is up to you. You also need a GameplayEffect Blueprint and you will add it to the ability’s cooldown gameplay effect section:


(GameplayAbility Blueprint details)

This will add this specific gameplay effect once you either call CommitAbility or CommitAbilityCooldown node in the ability blueprint. In my case, I want the cooldown to start when the ability ends, so right before calling endAbility, I commit the cooldown (could be commited at the start of the ability to start the cooldown at the start too!):


(GameplayAbility Graph)

This is all you need on the ability side. Now for the actual cooldown gameplay effect, you need to create the blueprint for it, and set its duration policy to “Has Duration” and in the duration magnitude section, you can use “Scalable Float”, and directly set the time you want the ability to be on cooldown for. It is also possible to use another magnitude Calculation Type, like “SetByCaller” to set the cooldown duration in the ability by using the
“Assign Set By Caller Magnitude” blueprint node, where you set matching “Data Name” on the node and in the gameplay effect and pass in the cooldown duration in the magnitude variable.

Now, here’s what I couldn’t find documentation about. You need to grant to the actor a “cooldown” tag, and in the tutorial or documentation around the web, this is where I would get stuck, as there would be a section in the gameplay effect blueprint about tags, but it is nowhere to be found in 5.3. So from my testing, you need to add a “Target Tags Gameplay Effect Component” in the components array, and add a cooldown tag from there:


(GameplayEffect Blueprint Details)

And that’s it. Once you commit the cooldown, this gameplay tag will be added to your actor, and it will automatically block the possiblity of activating the ability for the reminder of the duration.

9 Likes

THANK YOU! Was about to go crazy looking for where you add the tags

Thank you! I spend about 2 hours to find it!

First of all - THANK YOU!
Second, I wanted to add my addition, if you wish to set cooldown value by caller, you will have to do the following:

However, I’m not sure how this whole implementation works with 2 separate cooldowns for different abilities, I need to test this

3 Likes

Ok I can confirm my suspicion, having 2 or more abilities on cooldown will have to wait for all cooldowns to complete.
Taking a look at the Lyra project it is seems that each ability will have to have it’s own unique cooldown
Reference:

for example, GA_Grenade will have GE_Grenade_Cooldown
I think that there is a bug where the instigator of the effect is actually the player and not the ability, which means the caller is the player (or who ever called the ability)
It also might explain why do we have to grant (to the target) a cooldown tag in order for the ability have a cooldown, that is because in this case the target is also the instigator.

Yeah a cooldown Gameplay Effect needs to be created for every ability so they can each have their unique cooldown, which kinda makes sense? I wouldn’t use the same Cooldown gameplay effect for 2 different abilities even if their cooldown time is set by ref by caller since they’ll indeed be using the same gameplay effect to know when they can be activated again.

Unless you mean having stacks of the same ability which I didn’t dwelved in as of now since I won’t be needing that personnally.

Instigators are the “causing actors” of whatever an effect is. A Gameplay Ability is an UObject, but not an Actor, and thus cannot be an Instigator. So, the Instigator being the player is intentional, not a bug.

Awesome! This worked perfectly! I was wondering how you guys are displaying cooldowns using this system to the UI? Is there a way to retrieve the current duration of the cooldown, or do you guys setup a separate timer of the same duration and start it at the same time?

1 Like

I’d check the Tranek documentation for that, there’s a way to start the timer using gameplaytags event etc. and there’s also examples of that for for reloading displaying a timer if I remember correctly.

This didn’t work for me.

I have the same set up as you but when I plug in a variable to Magnitude it defaults to 1 for some reason.

Yeah I passed over that quickly in the post. For people having problem with that, you need to set the “magnitude calculation type” to SetByCaller in the gameplay effect so it takes into account the value you set in the ability blueprint using the “Assign tag set by caller magnitude” node.