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