How can I use the Get All Actors Of Class Matching Tag Query node?

I’m just now learning how to use Gameplay Tags due to a blog I found explaining what they were. I’ve started setting the system up for my game but I came across an issue with the Get All Actors Of Class Matching Tag Query node.

I want to use this node dynamically and create the query input it requires from a tag container variable. Does anyone know how to properly use this node and is there a reason it can’t be dynamic or am I just not seeing something?

Edit: Here is a better representation of what I was looking for.

Edit 2: Apparently this is an issue with the node itself since it requires an interface that doesn’t look like its exposed to blueprint. According to this video the node has issues with blueprint so does anyone know when this will be resolved?

1 Like

Same question here - would really love for this one to work.

Same here and extremely curious about how to use it

This approach should work.
Add a variable called tag of type integer to your blueprint.
Initialise this with a unique value say 0.

Then use the get all actor by class node
Loop over each item with a foreachloop
Take the element pin an connect it to a get tag node. Make sure context sensitive is unchecked
Then use a conditional statement to compare your tag value to 0.
If it matches then you have the reference to the instance of this class.

Interesting

So according to your Edit 2 - there is no way to use this node?

quick fix

To use GetAllActorsOfClassMatchingTagQuery, your classes have to implements the GameplayTagAssetInterface (see IGameplayTagAssetInterface | Unreal Engine 5.5 Documentation | Epic Developer Community)

To do so, you have to create a new C++ class like this

.Build.cs

[...]

PrivateDependencyModuleNames.AddRange(
	new string[]
    {

[...]

        "GameplayTags",

    });

[...]

.h

#include "CoreMinimal.h"
#include "Engine/GameInstance.h" 
#include "GameFramework/Actor.h"
#include "GameplayTagAssetInterface.h"

#include "MyActor.generated.h"

UCLASS()
class MY_API AMyActor : public AActor, public IGameplayTagAssetInterface
{

	GENERATED_BODY()

public:

	UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Gameplay", meta = (ToolTip = "Container for gameplay tags"))
	FGameplayTagContainer GameplayTags;

	UFUNCTION(BlueprintCallable, Category = "Gameplay")
	virtual void GetOwnedGameplayTags(FGameplayTagContainer& TagContainer) const;

.cpp


void AMyActor::GetOwnedGameplayTags(FGameplayTagContainer& TagContainer) const
{
	TagContainer = GameplayTags;
}

reason

A peep in the source code of UBlueprintGameplayTagLibrary make it clear how the GetAllActorsOfClassMatchingTagQuery is working.

in Unreal 5.4.4, BlueprintGameplayTagLibrary.cpp line 120, after getting all the actors of the specified class, the code validate the presence of the inteface.

				IGameplayTagAssetInterface* GameplayTagAssetInterface = Cast<IGameplayTagAssetInterface>(Actor);
				if (GameplayTagAssetInterface != nullptr)
				{

i hope it still helps :wink: