"Get All Actors Of Class" in C++

Or you can try this:

Searching for actors of C++ classes:
(Thanks gjudkins for reminding about it :slight_smile:

TArray<AActor*> FoundActors;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), YourClass::StaticClass(), FoundActors);

Searching for actors of BP classes:

TSubclassOf<AActor> ClassToFind; // Needs to be populated somehow (e.g. by exposing to blueprints as uproperty and setting it there

TArray<AActor*> FoundActors;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), ClassToFind, FoundActors);
8 Likes