Where should GEComponents be created in C++?

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!

2 Likes