GameplayStatics/GetAllActorsWithInterface

Find all Actors in the world with the specified interface. Include #include "Kismet/GameplayStatics.h" Syntax void GetAllActorsWithInterface(const UObject* WorldContextObject, TSubclassOf...

Updated about 5 years ago

Find all Actors in the world with the specified interface.

Include

#include "Kismet/GameplayStatics.h"

Syntax

void GetAllActorsWithInterface(const UObject* WorldContextObject, TSubclassOf Interface, TArray& OutActors)

Parameters

WorldContextObject

Any UObject that exists in the world.

Interface

The interface to find.

OutActors

Output array containing actors of the specified interface.

Examples

Real world use cases:

Example 1

TODO: Add more details

TSubclassOf SomeInterface;
...
TArray& OutActors;
GetAllActorsWithInterface(this, SomeInterface, OutActors);
for (AActor* SomeActor : OutActors) {
{
    // Use the found actors
}
This helps keep the lights on