Hi,
I’m using GAS and wanted to set up a resuable generic cooldown UGameplayEffect.
I was following the Tranek documention at GitHub · Where software is built, but it looks like that information of how to do that with an MMC is outdated.
When I add to the generic cooldown effect to a gameplay ability I get a validation error: CooldownGameplayEffectClass 'GE Cooldown' grants no tags. A GameplayEffect class must grant tags (Component: Grant Tags to Target Actor) to be used as cooldown.
But I don’t want to hardcode the tag(s) in the effect directly I want to pull them from the GameplayAbility dynamically.
Hi @FileNotFound ,Welcome back to the forums!
I’m sharing the official documentation where this topic is explained. It’s an article that addresses many of the common questions that can come up when setting up the Gameplay Ability System (GAS) in a project. It also clarifies that “best practices” can vary depending on the specific needs of each project, but it presents different approaches and considerations that might help you resolve your issue.
In addition, I’m including a couple of guides from the Learning site that demonstrate different ways to implement a generic cooldown in GAS,
along with a video that may also help you better understand the available alternatives.
I hope this documentation helps and clarifies the question you were dealing with.
Thanks for the response.
How ever this does not seem to solve my issue.
The GCD tutorial creates a global cooldown, but I want it the cooldown to be unique per ability and not block others.
The youtube link seems like what I want and what I tried to set up, the problem is he only shows and talks about the cost portion and never shows the setup for the cooldown effect.
In my own testing, I can get it to work if with the following steps:
Create cooldown effect with Apply Gameplay Tags Component.
Add Cooldown effect to ability and compile ability.
Go back to Cooldown effect and remove tags component and compile ability.
Now no validation error on ability and at run time works the way I would want.
The problem with this is 2 fold:
I would have to repeat this same back and forth dance for every new ability
Also for existing ability, because if I try to compile the ability after removing the tags component from the cooldown effect, the validation throws an error.
Is it possible to remove/disable the validation check for the Cooldown effect when compiling a Gameplayability?
One way would be to override the UGameplayAbility::ApplyCooldown() method to inject custom cooldown Tags.
For instance:
void UMyGameplayAbility::ApplyCooldown(
const FGameplayAbilitySpecHandle Handle,
const FGameplayAbilityActorInfo* ActorInfo,
const FGameplayAbilityActivationInfo ActivationInfo) const
{
const int32 AbilityLevel = GetAbilityLevel(Handle, ActorInfo);
// Check if we have a cooldown effect
const UGameplayEffect* CooldownEffectCDO = GetCooldownGameplayEffect();
if (!IsValid(CooldownEffectCDO))
{
return;
}
const FGameplayEffectSpecHandle CooldownSpecHandle = MakeOutgoingGameplayEffectSpec(CooldownEffectCDO->GetClass(), AbilityLevel);
// Check if we have valid cooldown tags
if (ExplicitCooldownTags.IsValid())
{
//CooldownSpecHandle.Data->AppendDynamicAssetTags(ExplicitCooldownAssetTags); one could also add explicit asset tags to the cooldown GE, but that's out of scope for now
CooldownSpecHandle.Data->DynamicGrantedTags.AppendTags(ExplicitCooldownTags);
}
else
{
ABILITY_LOG(Error, TEXT("ExplicitCooldownTags are not valid for ability %s. Cooldown will not be applied."), *GetName());
return;
}
// Apply cooldown
FActiveGameplayEffectHandle CooldownHandle =
ApplyGameplayEffectSpecToOwner(Handle, ActorInfo, ActivationInfo, CooldownSpecHandle);
}
Note that ExplicitCooldownTags is a FGameplayTagContainer I added to my base GameplayAbilityClass.
/** Explicit cooldown tags to apply when the explicit cooldown duration is used. */
UPROPERTY(EditDefaultsOnly, Category = "Cooldowns|Explicit")
FGameplayTagContainer ExplicitCooldownTags;
With the combination of a global cooldown with no tags and injecting per-ability cooldown tags, you shouldn’t have any issues like that anymore.
And as of 5.7 you need to set the console variable AbilitySystem.WarnCooldownEffectWithoutTags to 0.
Otherwise it will keep giving you warnings.