UGameplayStatics::GetAllActorsOfClassWithTag
#include "Kismet/GameplayStatics.h"
Access: public
Specifiers: staticBlueprintCallable
Description
Finds all actors of the specified class that also carry the given actor tag. More targeted than GetAllActorsWithTag when you already know the class.
Caveats & Gotchas
- • Still iterates every actor in the world; the class filter only reduces the result set, not the search cost. Avoid calling per-frame.
- • Both ActorClass and Tag must be valid — passing a null ActorClass or NAME_None for Tag produces an empty result with no warning.
- • Does not match component-level tags; only AActor::Tags is checked.
Signature
static ENGINE_API void GetAllActorsOfClassWithTag(const UObject* WorldContextObject, TSubclassOf<AActor> ActorClass, FName Tag, TArray<AActor*>& OutActors); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| WorldContextObject | const UObject* | Object used to retrieve the world context. | — |
| ActorClass | TSubclassOf<AActor> | Restricts the search to actors of this class or its subclasses. | — |
| Tag | FName | The actor tag to match. Must be non-None. | — |
| OutActors | TArray<AActor*>& | Output array of matching actors. | — |
Return Type
void Example
Find all enemy characters tagged as Elite C++
TArray<AActor*> Elites;
UGameplayStatics::GetAllActorsOfClassWithTag(
this, AEnemyCharacter::StaticClass(), FName("Elite"), Elites);
for (AActor* A : Elites)
{
Cast<AEnemyCharacter>(A)->SetBehaviorMode(EBehaviorMode::Aggressive);
} Tags
Version History
Introduced in: 4.14
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?