How do I use the FGameplayTagContainer and Tag Editor?

So I found this very nice module and I have two questions:

  1. Is it finished ? The editor part seem lack of the ability to actually add tags.

  2. Or tags are added by other means. If so, how ?

It’s now what I have in mind here.
This is what I’m talking about:
Engine/Source/Runtime/GameplayTags

Actors should have Tags array that is accessed via C++ and blueprints, i believe.

You can add tags via Defaults tab in blueprint editor or inside Details panel by going to Actor category and expanding it, you’ll see the same Tags property.

I can’t seem to add tags to an asset unless it’s actually ON the map - is it possible to add tags to a static mesh or the like even if it’s not on the map? I’d like to be able to do that so I can check for these tags when manipulating the object in a construction script.

Sorry for the confusion guys - GameplayTags are a separate, unrelated system to Actor Tags. GameplayTags is a more advanced/robust system but requires data assets to populate the tag lists. We haven’t written any docs or tutorials on GameplayTags yet.

To create tags in the editor you need to import them from a CSV file. They cannot be edited/created directly in the editor (for now at least). To import from a CSV, you need to right click in the content browser and select import, then locate a .CSV with tag data (see below), select DataTable → GameplayTagTable.

Here is an example for the GameplayTagTable format. Internally we use Excel to maintain these tables and export them as CSVs with macros. Again this is stuff our game teams have been using but not really a feature of the engine that has been given much polish for outside consumption. Over time we expect this to evolve into a more user friendly system.

,Tag,CategoryText
0,Damage.Burning,
1,Damage.Poison,
2,Damage.Ice,
3,Cooldown.Global,
4,Cooldown.TestAbility,
5,ResouceCost.Mana.TestAbility,

Save that into a .CSV - you should be able to import it into the engine.

Sorry, forgot more. The idea is that you have 1 dictionary of gameplay tags (added/imported like above). Somewhere in your game code on startup, you need to tell the GameplayTags system. Something like this:

IGameplayTagsModule& GameplayTagsModule =  IGameplayTagsModule::Get();
	GameplayTagsModule.GetGameplayTagsManager().LoadGameplayTagTable(GameplayTagTableName);

This needs to be done at editor startup too… so the correct way is to make a UEngine subclass for your game. But that is a lot of steps. It is probably easiest to stick the above line somewhere in UEngine::Init.

Thanks. That means I have to build engine from source ?
Not an big deal for me, but seems bit daunting to put such specific game thing, this high in engine hierarchy.

In any case I started using this module, for my project and I must say it is extremely useful I love it. Would love it even more if the ability to add tags was easier, preferably directly in editor (:.

Yeah, future versions will make this easier. Technically you don’t need to build engine source - you can subclass UEngine and UEditorEngine in your project and do your dictionary loading in UYourGameEngine::Init().

The problem isn’t trivial since the global dictionary needs to be loaded before your game assets try to load (or rather, the dictionary needs to be specified since references to tags in your dictionary only store the index into the dictionary, not a reference to the dictionary itself).

As this system was brought up in our projects which already had their own UEngine/UEditorEngine subclasses, it was easy to specify the global dictionaries there. For smaller team projects where they won’t need to their own engine subclasses, we will need to find a better way of loading the global dictionary.

Edit - Index is actually wrong. I believe tags are stored as text but they need to resolve to a stable index independent of load order. A solvable problem in many ways, the easiest being right now to specify a dictionary before loading any.

I downloaded new preview build (4.2) and tried to to actually include GameplayTags in GameEngine.cpp Init function.

But seems like I have trouble to get it working.I tried adding “GameplayTags”, in Engine.Build.cs in various places (DynamicallyLoaded, Private, Public),
As well ad adding public and private IncludePaths.

I somehwat managed to compile it but then:

Classes/GameplayTagsManager.h(5): fatal error C1083: Cannot open include file: ‘GameplayTagsManager.generated.h’

Could explain in few words what’s wrong ?

Did the file get generated and just can’t be found, or is it not getting generated? It would be here:

Engine\Intermediate\Build\Win64\Inc\GameplayTags\GameplayTagContainer.generated.h

It got generated it just Couldn’t be found. Now I changed few things and I have link error, here is exact setup I’m using right now:
Engine.build.cs:

	PrivateIncludePathModuleNames.AddRange(
		new string[] {
			(...)
        "GameplayTags"
		}

PublicIncludePaths.AddRange(
new string[] {
        "Runtime/GameplayTags/Public"
				    // ... add public include paths required here ...
			    }
);

	PrivateIncludePaths.AddRange(
		new string[] {
			(..)
        "Runtime/GameplayTags/Private"
		}
	);

in GameEngine.cpp:

#include "GameplayTagsModule.h"
#include "GameplayTags.h"


void UGameEngine::Init(IEngineLoop* InEngineLoop)
{
	DECLARE_SCOPE_CYCLE_COUNTER(TEXT("UGameEngine Init"), STAT_GameEngineStartup, STATGROUP_LoadTime);

	// Call base.
	UEngine::Init(InEngineLoop);

	//GameplayTags:
	IGameplayTagsModule& GameplayTagsModule = IGameplayTagsModule::Get();
	GameplayTagsModule.GetGameplayTagsManager().LoadGameplayTagTable("Tags");

Module.Engine.9_of_44.cpp.obj : error LNK2019: unresolved external symbol “public: class UDataTable const * __cdecl UGameplayTagsManager::LoadGameplayTagTable(class FString)” (?LoadGameplayTagTable@UGameplayTagsManager@@QEAAPEBVUDataTable@@VFString@@@Z) referenced in function “public: virtual void __cdecl UGameEngine::Init(class IEngineLoop *)” (?Init@UGameEngine@@UEAAXPEAVIEngineLoop@@@Z)

edit:I changed where the “GameplayTags” is to:

	DynamicallyLoadedModuleNames.AddRange(
		new string[]
		{
                (..)
        "GameplayTags"
		}
	);

I get this error:
GameplayTagAssetInterface.h(5): fatal error C1083: Cannot open include file: ‘GameplayTagAssetInterface.generated.h’: No such file or directory

And the file is in Intermediate folder.

Can you try just adding “GameplayTags” to the PublicDependencyModuleNames array?

I am not an expert on the UnrealBuiltTool chain. Its a very odd problem though. The intermediate directories should be auto included. If the above doesn’t do anything I will get someone with more UBT knowledge to help.

When I add it to PublicDependencyModuleNames I get huge list of unresolved dependencies, and it don’t it even start compilation.

Err yeah, that is probably introducing a cyclic dependency. Sorry, I’ve never set up a project like this. You may need to subclass UEngine for your project. I can noodle with this a bit if I get time this weekend, or you may just want to wait until this is a more polished/complete module.

It would nice if you could post crash course to what is needed to implement custom engine class.
Which functions to overload and how to get the custom engine class load.
From that point I should be able to just rewrite engine class from source.
It’s not pressing, but I’d really like to get it working.

In any case thanks for your help!

Ok My previous issue is solved. I managed to override engine classes. Wasn’t that hard after all, I just specified wrong paths to classes in DefaultEngine.ini in my project.

I added in init section:

IGameplayTagsModule& GameplayTagsModule = IGameplayTagsModule::Get();
GameplayTagsModule.GetGameplayTagsManager().LoadGameplayTagTable("Tags'");

But it seems like It doesn’t work.

I have this Table of tags (thanks for sample data!)
DataTable’/Game/Blueprints/Tags.Tags’

And in LoadGameplayTagsTable I tried few variations, including full path Tags.Tags, just Tags, but it seems like my table is not loaded

I have debugged it and it seems like LoadGameplayTagTable, can’t find my table.

Is there anything special, about where that data should be stored, or how should I specify path to it ?

You’ll need to specify the full path. So try:

GameplayTagsModule.GetGameplayTagsManager().LoadGameplayTagTable("/Game/Blueprints/Tags.Tags’");

Hm it seems, like tags are not loaded. I fallowed debug, and function is fired, but it seems it can’t resolve the path for asset and do not read tags from file.

Unless it is intended behavior that tags do not show up, when I click Edit button in editor ?

Edit:

After re importing assets, tags show, in the tag editor. So I guess it is bug.

So when UGameplayTagsManager::LoadGameplayTagTable is getting called, and the call to LoadObject is failing? That would be the thing to debug. I would suspect its either not finding the asset or its not recognizing the asset as a DataTable type. Both seem unlikely =\