GameplayStatics/GetAllActorsOfClass
Find all Actors in the world of the specified class. Include #include "Kismet/GameplayStatics.h" Syntax static void GetAllActorsOfClass(const UObject* WorldContextObject, TSubclassOf Acto...
Find all Actors in the world of the specified class.
Include
#include "Kismet/GameplayStatics.h"
Syntax
static void GetAllActorsOfClass(const UObject* WorldContextObject, TSubclassOf ActorClass, TArray& OutActors)
Parameters
WorldContextObject
Any UObject that exists in the world.
ActorClass
The class of actors which you want to find.
OutActors
Output array containing found actors (if any).
Examples
Real world use cases:
Example 1
TODO: Add more details
TSubclassOf SomeActorClass;
...
TArray& OutActors;
UGameplayStatics::GetAllActorsOfClass(this, SomeActorClass, OutActors);
for (AActor* SomeActor : OutActors) {
{
// Use the found actors
}