GameplayStatics/GetAllActorsWithTag

Find all Actors in the world with the specified tag. Include #include "Kismet/GameplayStatics.h" Syntax static void GetAllActorsWithTag(const UObject* WorldContextObject, FName Tag, TArra...

Updated over 4 years ago Edit Page Revisions

Find all Actors in the world with the specified tag.

Include

#include "Kismet/GameplayStatics.h"

Syntax

static void GetAllActorsWithTag(const UObject* WorldContextObject, FName Tag, TArray& OutActors)

Parameters

WorldContextObject

Any UObject that exists in the world.

Tag

The tag of actor which you want to find.

OutActors Output array containing actors with the specified tag.

Examples

Real world use cases:

Example 1

TODO: Add more details

FName SomeTag;
...
TArray& OutActors;
UGameplayStatics::GetAllActorsWithTag(this, SomeTag, OutActors)
for (AActor* SomeActor : OutActors) {
{
    // Use the found actors
}