After the changes to GAS in UE 5.3, I saw that GameplayEffects use Components when requiring/applying GamplayTags. So I tried to transfer all the GameplayTags logic from the GE’s C++ Constructor to GEComponents, but I couldn’t find where exactly should I create Components. The constructor didn’t work because they don’t have a Name or something, then I tried in PostInitProperties but my OngoingTagRequirements didn’t work after creating a build.
May someone tell me where should GEComponents be created in C++?
I’m interested to know what the intended place is too. It looks like you can override UGameplayEffect::PostCDOCompiled, add the components yourself and then call super which has backwards compatiblity that will work with your manually added components. However, that only works in Editor builds.
I know this is a late reply, but I recently encountered the same issue. In my case, the GEComponents
array in the GameplayEffect
class needed to be initialized correctly to resolve the console error. I treated it like any other component by creating it with CreateDefaultSubobject
and adding it directly to the GEComponents
array. Here’s the code that worked for me:
#pragma once
#include "CoreMinimal.h"
#include "GameplayEffect.h"
#include "GameplayEffectComponents/TargetTagsGameplayEffectComponent.h"
#include "UCustomEffect.generated.h"
/**
*
*/
UCLASS()
class ARCANA_API UCustomEffect : public UGameplayEffect
{
GENERATED_BODY()
public:
UCustomEffect()
{
DurationPolicy = EGameplayEffectDurationType::Infinite;
UTargetTagsGameplayEffectComponent* TagsComponent = CreateDefaultSubobject<UTargetTagsGameplayEffectComponent>(
TEXT("TagsComponent")
);
GEComponents.Add(TagsComponent);
FInheritedTagContainer Tags = TagsComponent->GetConfiguredTargetTagChanges();
Tags.AddTag(FGameplayTag::RequestGameplayTag(FName("Your.Tag.Name")));
TagsComponent->SetAndApplyTargetTagChanges(Tags);
}
};
I hope this helps!