{"id":106,"date":"2022-01-15T06:18:45","date_gmt":"2022-01-15T06:18:45","guid":{"rendered":"https:\/\/www.thegames.dev\/?p=106"},"modified":"2024-01-27T15:56:23","modified_gmt":"2024-01-27T15:56:23","slug":"native-gameplay-tags-new-in-4-27-and-ue5","status":"publish","type":"post","link":"https:\/\/www.thegames.dev\/?p=106","title":{"rendered":"Native Gameplay Tags (New in 4.27 and UE5)"},"content":{"rendered":"\n<p>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!<\/p>\n\n\n\n<p>This class adds the following macros:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: Relevant Code:; notranslate\" title=\"Relevant Code:\">\n\/**\n * 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.\n *\/\n#define UE_DECLARE_GAMEPLAY_TAG_EXTERN(TagName)\n\n\/**\n * Defines a native gameplay tag that is externally declared in a header to allow other modules or code to use the created tag variable. (4.27 and 5.0 only)\n *\/\n#define UE_DEFINE_GAMEPLAY_TAG(TagName, Tag) (4.27 and 5.0 only)\n\n\/**\n * Defines a native gameplay tag with a comment that is externally declared in a header to allow other modules or code to use the created tag variable. 5.1+ only\n *\/\n#define UE_DEFINE_GAMEPLAY_TAG_COMMENT(TagName, Tag, Comment) (5.1+ only)\n\n\/**\n * Defines a native gameplay tag such that it&#039;s only available to the cpp file you define it in.\n *\/\n#define UE_DEFINE_GAMEPLAY_TAG_STATIC(TagName, Tag)\n<\/pre><\/div>\n\n\n<p>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. I do recommend wrapping them in a namespace to avoid global pollutions. Example here:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: Relevant Code:; notranslate\" title=\"Relevant Code:\">\n\nnamespace KaosGameplayAbilityTags \n{\n\tUE_DEFINE_GAMEPLAY_TAG_STATIC(TAG_Gameplay_Action_Player_AimDownsights, &quot;Gameplay.Ability.AimDownSights&quot;);\n\tUE_DEFINE_GAMEPLAY_TAG_STATIC(TAG_Gameplay_Status_AimingDownSights, &quot;Gameplay.Status.AimingDownSights&quot;);\n}\n\nUKaosGameplayAbility_ADS::UKaosGameplayAbility_ADS()\n{\n\tNetExecutionPolicy = EGameplayAbilityNetExecutionPolicy::LocalPredicted;\n\tNetSecurityPolicy = EGameplayAbilityNetSecurityPolicy::ClientOrServer;\n\tActivationOwnedTags.AddTagFast(KaosGameplayAbilityTags::::TAG_Gameplay_Status_AimingDownSights);\n\tAbilityTags.AddTagFast(KaosGameplayAbilityTags::TAG_Gameplay_Action_Player_AimDownsights);\n}\n<\/pre><\/div>\n\n\n<p>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!<\/p>\n\n\n\n<p>The other two macros need to work in tandem, and they can be used in a header file for example, &#8220;MyGameplayTags.h&#8221;<br>with an example below:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: Relevant Code:; notranslate\" title=\"Relevant Code:\">\n\/\/ Copyright InterKaos Games. All Rights Reserved.\n\n#pragma once\n\n#include &quot;CoreMinimal.h&quot;\n\nnamespace MyGamesTags\n{\n\tUE_DECLARE_GAMEPLAY_TAG_EXTERN(TAG_Gameplay_Status_Dead);\n\tUE_DECLARE_GAMEPLAY_TAG_EXTERN(TAG_AbilityActivation_Fail_Dead);\n}\n<\/pre><\/div>\n\n\n<p>with the corresponding line in the cpp file:<\/p>\n\n\n\n<p>(UE 4.27 and 5.0)<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: Relevant Code:; notranslate\" title=\"Relevant Code:\">\n\/\/ Copyright InterKaos Games. All Rights Reserved.\n\n#include &quot;KaosNativeTags.h&quot;\n\nnamespace MyGamesTags\n{\n\tUE_DEFINE_GAMEPLAY_TAG(TAG_Gameplay_Status_Dead, &quot;Gameplay.Status.Dead&quot;)\n\tUE_DEFINE_GAMEPLAY_TAG(TAG_AbilityActivation_Fail_Dead, &quot;AbilityActivation.Fail.Dead&quot;)\n}\n<\/pre><\/div>\n\n\n<p>(UE 5.1+)<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: Relevant Code:; notranslate\" title=\"Relevant Code:\">\n\/\/ Copyright InterKaos Games. All Rights Reserved.\n\n#include &quot;KaosNativeTags.h&quot;\n\nnamespace MyGamesTags\n{\n\tUE_DEFINE_GAMEPLAY_TAG_COMMENT(TAG_Gameplay_Status_Dead, &quot;Gameplay.Status.Dead&quot;, &quot;Tag applied to actor when they are dead&quot;)\n\tUE_DEFINE_GAMEPLAY_TAG_COMMENT(TAG_AbilityActivation_Fail_Dead, &quot;AbilityActivation.Fail.Dead&quot;, &quot;Ability failed to activate cause the AvatarActor was dead.&quot;)\n}\n<\/pre><\/div>\n\n\n<p>We can then include the header file &#8220;KaosNativeTags.h&#8221; in any .cpp file, and use the corresponding tag<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: Relevant Code:; notranslate\" title=\"Relevant Code:\">\n\t\t\tif (OptionalRelevantTags &amp;&amp; AbilitySystemComponentTags.HasTag(MyGamesTags::TAG_Gameplay_Status_Dead))\n\t\t\t{\n\t\t\t\t\/\/ If player is dead and was rejected due to blocking tags, give that feedback\n\t\t\t\tOptionalRelevantTags-&gt;AddTag(MyGamesTags::TAG_AbilityActivation_Fail_Dead);\n\t\t\t}\n<\/pre><\/div>\n\n\n<p>Since UE 5.1 there is now a way to comment tags. Before this you had no way to add comments to native tags.<br><br>One more thing of note, sometimes packaging issues can happen, and this can be solved by shadowing the tag inside DefaultGameplayTags.ini.<\/p>\n\n\n\n<p>With that, hopefully you can make use of these in your game code!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 <a href=\"https:\/\/www.thegames.dev\/?p=106\" class=\"more-link\">&#8230;<span class=\"screen-reader-text\">  Native Gameplay Tags (New in 4.27 and UE5)<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-106","post","type-post","status-publish","format-standard","hentry","category-gameplay-ability-system"],"rise-blocks_total_comments":0,"rise-blocks_categories":[{"term_id":4,"name":"Gameplay Ability System","slug":"gameplay-ability-system","term_group":0,"term_taxonomy_id":4,"taxonomy":"category","description":"Unreal Engine's Gameplay Ability System (GAS)","parent":2,"count":16,"filter":"raw","cat_ID":4,"category_count":16,"category_description":"Unreal Engine's Gameplay Ability System (GAS)","cat_name":"Gameplay Ability System","category_nicename":"gameplay-ability-system","category_parent":2}],"rise-blocks_excerpt":"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: We will start..","_links":{"self":[{"href":"https:\/\/www.thegames.dev\/index.php?rest_route=\/wp\/v2\/posts\/106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thegames.dev\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thegames.dev\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thegames.dev\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thegames.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=106"}],"version-history":[{"count":10,"href":"https:\/\/www.thegames.dev\/index.php?rest_route=\/wp\/v2\/posts\/106\/revisions"}],"predecessor-version":[{"id":230,"href":"https:\/\/www.thegames.dev\/index.php?rest_route=\/wp\/v2\/posts\/106\/revisions\/230"}],"wp:attachment":[{"href":"https:\/\/www.thegames.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thegames.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thegames.dev\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}