UGameplayStatics::GetAllActorsWithInterface
#include "Kismet/GameplayStatics.h"
Access: public
Specifiers: staticBlueprintCallable
Description
Finds every actor in the world that implements the specified UInterface. The header explicitly warns this is very slow as it iterates over every actor.
Caveats & Gotchas
- • This iterates the entire actor list every call — O(n) over all world actors. Never call this every frame or in tight loops; cache results and refresh on demand.
- • Actors that implement the interface via a Blueprint-implemented interface (BPI) are included, but only if the Blueprint class is properly registered; actors pending kill are excluded.
- • Passing a null Interface results in an empty OutActors without an engine error, making silent failures easy to introduce if the interface asset gets deleted or renamed.
Signature
static ENGINE_API void GetAllActorsWithInterface(const UObject* WorldContextObject, TSubclassOf<UInterface> Interface, TArray<AActor*>& OutActors); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| WorldContextObject | const UObject* | Object used to retrieve the world context. | — |
| Interface | TSubclassOf<UInterface> | The interface class to search for. Must be non-null or the output array will be empty. | — |
| OutActors | TArray<AActor*>& | Output array populated with all actors implementing the interface. | — |
Return Type
void Example
Notify all interactable actors in the world C++
TArray<AActor*> Interactables;
UGameplayStatics::GetAllActorsWithInterface(this, UInteractableInterface::StaticClass(), Interactables);
for (AActor* Actor : Interactables)
{
IInteractableInterface::Execute_OnInteract(Actor, PlayerController);
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?