Navigation
API > API/Runtime > API/Runtime/GameplayTags
An FGameplayTagQuery is a logical query that can be run against an FGameplayTagContainer. A query that succeeds is said to "match". Queries are logical expressions that can test the intersection properties of another tag container (all, any, or none), or the matching state of a set of sub-expressions (all, any, or none). This allows queries to be arbitrarily recursive and very expressive. For instance, if you wanted to test if a given tag container contained tags ((A && B) || (C)) && (!D), you would construct your query in the form ALL( ANY( ALL(A,B), ALL(C) ), NONE(D) )
You can expose the query structs to Blueprints and edit them with a custom editor, or you can construct them natively in code.
Example of how to build a query via code: FGameplayTagQuery Q; Q.BuildQuery( FGameplayTagQueryExpression() .AllTagsMatch() .AddTag(FGameplayTag::RequestGameplayTag(FName(TEXT("Animal.Mammal.Dog.Corgi")))) .AddTag(FGameplayTag::RequestGameplayTag(FName(TEXT("Plant.Tree.Spruce")))) );
Queries are internally represented as a byte stream that is memory-efficient and can be evaluated quickly at runtime. Note: these have an extensive details and graph pin customization for editing, so there is no need to expose the internals to Blueprints.
| Name | FGameplayTagQuery |
| Type | struct |
| Header File | /Engine/Source/Runtime/GameplayTags/Classes/GameplayTagContainer.h |
| Include Path | #include "GameplayTagContainer.h" |
Syntax
USTRUCT (BlueprintType ,
Meta=(HasNativeMake="/Script/GameplayTags.BlueprintGameplayTagLibrary.MakeGameplayTagQuery"))
struct FGameplayTagQuery
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FGameplayTagQuery
(
FGameplayTagQuery&& Other |
GameplayTagContainer.h | ||
FGameplayTagQuery
(
FGameplayTagQuery const& Other |
GameplayTagContainer.h | ||
| GameplayTagContainer.h |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| EmptyQuery | const FGameplayTagQuery | GameplayTagContainer.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| AutoDescription | FString | Auto-generated string describing the query | GameplayTagContainer.h |
|
| QueryTokenStream | TArray< uint8 > | Stream representation of the actual hierarchical query | GameplayTagContainer.h |
|
| TagDictionary | TArray< FGameplayTag > | List of tags referenced by this entire query. Token stream stored indices into this list. | GameplayTagContainer.h |
|
| TokenStreamVersion | int32 | Versioning for future token stream protocol changes. See EGameplayTagQueryStreamVersion. | GameplayTagContainer.h |
|
| UserDescription | FString | User-provided string describing the query | GameplayTagContainer.h |
|
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void Build
(
FGameplayTagQueryExpression& RootQueryExpr, |
Creates this query with the given root expression. | GameplayTagContainer.h | |
void BuildFromEditableQuery
(
UEditableGameplayTagQuery& EditableQuery |
Creates this query based on the given EditableQuery object | GameplayTagContainer.h | |
void Clear() |
Resets this query to its default empty state. | GameplayTagContainer.h | |
UEditableGameplayTagQuery * CreateEditableQuery() |
Creates editable query object tree based on this query | GameplayTagContainer.h | |
const FString & GetDescription() |
Returns description string. | GameplayTagContainer.h | |
void GetGameplayTagArray
(
TArray< FGameplayTag >& OutGameplayTags |
Gets the explicit list of all unique gameplay tags referenced by the query. | GameplayTagContainer.h | |
const TArray< FGameplayTag > & GetGameplayTagArray () |
Gets the explicit list of all unique gameplay tags referenced by the query. | GameplayTagContainer.h | |
void GetQueryExpr
(
FGameplayTagQueryExpression& OutExpr |
Builds a FGameplayTagQueryExpression from this query. | GameplayTagContainer.h | |
bool IsEmpty() |
Returns true if this query is empty, false otherwise. | GameplayTagContainer.h | |
bool Matches
(
FGameplayTagContainer const& Tags |
Returns true if the given tags match this query, or false otherwise. | GameplayTagContainer.h | |
void ReplaceTagFast
(
FGameplayTag const& Tag |
Replaces existing tags with passed in tag. | GameplayTagContainer.h | |
void ReplaceTagsFast
(
FGameplayTagContainer const& Tags |
Replaces existing tags with passed in tags. | GameplayTagContainer.h | |
void Serialize
(
FArchive& Ar |
Serialize the tag query | GameplayTagContainer.h | |
void SetUserDescription
(
const FString& InUserDescription |
Sets the user-specified description of this query. | GameplayTagContainer.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static FGameplayTagQuery BuildQuery
(
FGameplayTagQueryExpression& RootQueryExpr, |
Static function to assemble and return a query. | GameplayTagContainer.h | |
static FGameplayTagQuery MakeQuery_ExactMatchAllTags
(
FGameplayTagContainer const& InTags |
GameplayTagContainer.h | ||
static FGameplayTagQuery MakeQuery_ExactMatchAnyTags
(
FGameplayTagContainer const& InTags |
GameplayTagContainer.h | ||
static FGameplayTagQuery MakeQuery_MatchAllTags
(
FGameplayTagContainer const& InTags |
GameplayTagContainer.h | ||
static FGameplayTagQuery MakeQuery_MatchAnyTags
(
FGameplayTagContainer const& InTags |
Shortcuts for easily creating common query types Creates a tag query that will match if there are any common tags between the given tags and the tags being queries against. | GameplayTagContainer.h | |
static FGameplayTagQuery MakeQuery_MatchNoTags
(
FGameplayTagContainer const& InTags |
GameplayTagContainer.h | ||
static FGameplayTagQuery MakeQuery_MatchTag
(
FGameplayTag const& InTag |
GameplayTagContainer.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
bool operator!=
(
const FGameplayTagQuery& Other |
GameplayTagContainer.h | ||
FGameplayTagQuery & operator=
(
FGameplayTagQuery const& Other |
Assignment/Equality operators | GameplayTagContainer.h | |
FGameplayTagQuery & operator=
(
FGameplayTagQuery&& Other |
GameplayTagContainer.h | ||
bool operator==
(
const FGameplayTagQuery& Other |
GameplayTagContainer.h |