SetAndApplyTargetTagChanges isn't working on a UTargetTagsGameplayEffectComponent (C++)

So, I was learning how to use GAS and the course I was using to learn used this method to add a tag to a gameplay effect that would be added to the actor it would be applied to:

However, I noticed the tags isn’t being added and this line of code is deprecated:

After that I remembered that now we need to add components to add the tags on them, and so, I wrote this:

	UTargetTagsGameplayEffectComponent& Component = Effect->AddComponent<UTargetTagsGameplayEffectComponent>();
	FInheritedTagContainer TagContainer = FInheritedTagContainer();
	TagContainer.AddTag(AuraTags.DamageTypesToDebuffs[DamageType]);
	Component.SetAndApplyTargetTagChanges(TagContainer);

It does create the component, but the tag itself isn’t being added to it:


It was supposed to be adding a tag “Debuff.Burn” to the added/combined tags. Am I doing it wrong?

Solved it, I didn’t know I had to add added before adding the tag

In 5.3.2 works only like this

FInheritedTagContainer TagContainer = FInheritedTagContainer();
	UTargetTagsGameplayEffectComponent& Component = GameplayEffect->FindOrAddComponent<UTargetTagsGameplayEffectComponent>();
	TagContainer.Added.AddTag(GameplayTags.DamageTypesToDebuffs[DamageType]);
	TagContainer.CombinedTags.AddTag(GameplayTags.DamageTypesToDebuffs[DamageType]);
	Component.SetAndApplyTargetTagChanges(TagContainer);

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