How to add a Gameplay tag to an actor c++

Hiya,
I’m trying to add a Gameplay tag to an actor or to a GameplayTagContainer on an actor from a data table in C++ and can’t work out how to do it. I have followed the instructions at Gameplay Tags | Unreal Engine Documentation and have created my data table and added it to the GameplayTagTableList in the Project Settings.

I’ve then created a FGameplayTagContainer InteractableTags struct in my header file and in my .cpp file put InteractableTags.AddTag(“Interactable”); in my constructor as indicated here Using Gameplay Tags to Label and Organize Your Content in UE4 - Unreal Engine

Unfortunately I get a "no suitable constructor exists to convert from “const char[13] to “FGameplayTag”” intellisense error and my project won’t compile.

I can add a tag from my data table to an actor in blueprint so I know that the table is registering with the GameplayTagsManager. I’ve tried including any header files related to gameplaytags and nothing seems to work.

Any ideas?

Header:

#pragma once

#include "CoreMinimal.h"
#include "BuilderBaseSelectableActor.h"
#include "BuilderTile.generated.h"

/**
 * 
 */

UCLASS()
class BUILDER_API ABuilderTile : public ABuilderBaseSelectableActor
{
	GENERATED_BODY()
	
public:
	ABuilderTile();

	UPROPERTY()
	FGameplayTagContainer InteractableTags;
    	
};

.cpp

#include "BuilderTile.h"
#include "GameplayTags/Classes/GameplayTagsManager.h"
#include "GameplayTags/Classes/GameplayTagContainer.h"
#include "GameplayTagsModule.h"
#include "GameplayTagsSettings.h"
#include "GameplayTags.h"
#include "GameplayTagsManager.h"

ABuilderTile::ABuilderTile()
{
	InteractableTags.AddTag("Interactable");
	
}

The argument is const FGameplayTag & not FString. So you need to make FGameplayTag, if you look on API refrence:

you can find this:

So:

InteractableTags.AddTag(FGameplayTag::RequestGameplayTag(FName("Interactable")));
2 Likes

Ah! Thank you! You’ve saved my sanity

Thanks !