Dynamic Gameplay Tags Disappear After Applying Gameplay Effects in GAS

Hello all! I’m encountering an issue with dynamic gameplay tags in Unreal Engine 5 while using the Gameplay Ability System (GAS). My system applies GameplayEffect Specs dynamically to an AbilitySystemComponent (ASC) and uses AddDynamicAssetTag() to attach gameplay tags at runtime. However, the dynamic tags seem to disappear from the ASC after the GameplayEffect is applied (do note that I apply multiple of these GameplayEffect Specs to the same ASC).

Here’s what I’m experiencing:

  1. The tags are correctly added to the FGameplayEffectSpec before applying the GameplayEffect. I confirmed this by checking DynamicAssetTags on the spec before calling ApplyGameplayEffectSpecToSelf().

  2. After applying the GameplayEffect, the dynamic tags are no longer present in the ASC’s owned tags. I checked this using ASC->GetOwnedGameplayTags() and verified that other effects (like attribute changes) from the GameplayEffect are still applied.

  3. The tags are not persistent, even though I expect them to last as long as the GameplayEffect is active.

Here’s a simplified example of my code:

FGameplayEffectSpecHandle specHandle = ASC->MakeOutgoingSpec(effectClass, 1.f, ASC->MakeEffectContext());
if (specHandle.IsValid())
{
    FGameplayTag customTag = UGameplayTagsManager::Get().RequestGameplayTag(FName("CustomTag.Example"));
    specHandle.Data->AddDynamicAssetTag(customTag);

    FActiveGameplayEffectHandle newHandle = ASC->ApplyGameplayEffectSpecToSelf(*specHandle.Data.Get());
    if (newHandle.IsValid())
    {
        UE_LOG(LogTemp, Log, TEXT("AppliedGameplayEffect with tag: %s"), *customTag.ToString());
    }
}

Later, when I query the ASC for owned tags like this:

FGameplayTagContainer appliedTags;
ASC->GetOwnedGameplayTags(appliedTags);

for (const FGameplayTag& tag : appliedTags)
{
    UE_LOG(LogTemp, Log, TEXT("Tag on ASC: %s"), *tag.ToString());
}

TLDR:

  1. Why are the dynamic tags disappearing after applying the GameplayEffect?
  2. Are there additional settings or steps required to make sure dynamic tags persist while the GameplayEffect Spec is active?
  3. Is this the intended behavior of dynamic tags, or could this be a bug?

Any insights or advice would be amazing!

Hello everyone! Just for anyone who needs help with this in the future, I found the solution.

So, when you want to add tags to a GameplayEffect Spec at runtime, you’re going to want to use:
specHandle.Data.Get()->DynamicGrantedTags.AddTag(shapeTag);

And NOT use:
specHandle.Data->AddDynamicAssetTag(shapeTag);

This is because specHandle.Data->AddDynamicAssetTag(shapeTag); adds a tag into the GameplayEffects DynamicAssetTags container, which is mainly metadata on the FGameplayEffectSpec itself. For the ASC to actually “have” a gameplay tag from a GameplayEffect, the tag must be a “granted tag”. So, we have to add to the FGameplayEffectSpecs granted tags.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.