Native Gameplay Tags (New in 4.27 and UE5)

This is a quick run down on the new NativeGameplayTags which was added to UE4.27 and UE5. These tags will populate the Editor GameplayTags drop down also (same as my struct version). Though you can also add these tags to your DefaultGameplayTags.ini just fine, as the engine will not allow dupes!

This class adds the following macros:

 * Declares a native gameplay tag that is defined in a cpp with UE_DEFINE_GAMEPLAY_TAG to allow other modules or code to use the created tag variable.

 * Defines a native gameplay tag that is externally declared in a header to allow other modules or code to use the created tag variable.
#define UE_DEFINE_GAMEPLAY_TAG(TagName, Tag)

 * Defines a native gameplay tag such that it's only available to the cpp file you define it in.

I will explain how to use these, and i use these in combination with the struct version mentioned previously:

We will start with the simplest one, UE_DEFINE_GAMEPLAY_TAG_STATIC. This is only used in your .cpp files, and allows usage of that tag only in that file. Useful for a quick one off tag. Example here:

UE_DEFINE_GAMEPLAY_TAG_STATIC(Tag_Gameplay_Action_Player_AimDownsights, "Gameplay.Action.Player.AimDownsights");
UE_DEFINE_GAMEPLAY_TAG_STATIC(Tag_Gameplay_Status_Targeting, "Gameplay.Status.IsTargeting");

	NetExecutionPolicy = EGameplayAbilityNetExecutionPolicy::LocalPredicted;
	NetSecurityPolicy = EGameplayAbilityNetSecurityPolicy::ClientOrServer;

As you can see, we define these tags, and use the Name to use them. Benefit to this is we can use these in the constructor!

The other two macros need to work in tandem, and they can be used in a header file for example, “MyGameplayTags.h”
with an example below:

// Copyright InterKaos Games. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"


with the corresponding line in the cpp file:

// Copyright InterKaos Games. All Rights Reserved.

#include "KaosNativeTags.h"

UE_DEFINE_GAMEPLAY_TAG(TAG_Gameplay_Status_Dead, "Gameplay.Status.Dead")

We can then include the header file “KaosNativeTags.h” in any .cpp file, and use the corresponding tag

			const FKaosGameplayTags& GameplayTags = FKaosGameplayTags::Get();
			if (OptionalRelevantTags && AbilitySystemComponentTags.HasTag(TAG_Gameplay_Status_Dead))
				// If player is dead and was rejected due to blocking tags, give that feedback

There is one draw back to these tags, is there is no “DevComment”, it is possible to modify these macro’s to supply one.

With that, hopefully you can make use of these in your game code!