RealDocs

AActor::GetOverlappingActors

function Engine Blueprint Since 4.0
#include "GameFramework/Actor.h"
Access: public Specifiers: UFUNCTIONBlueprintCallable

Description

Populates an array with all actors currently overlapping any component of this actor. Does not include the actor itself.

Signature

void GetOverlappingActors(TArray<AActor*>& OverlappingActors, TSubclassOf<AActor> ClassFilter = nullptr) const

Parameters

Name Type Description Default
OverlappingActors TArray<AActor*>& Output array filled with actors currently overlapping this actor.
ClassFilter TSubclassOf<AActor> If set, only actors of this class or subclasses are included. nullptr

Return Type

void

Caveats & Gotchas

  • Only works if at least one component on this actor has 'Generate Overlap Events' enabled.
  • Results reflect the overlap state at the time of the call, which is updated at the end of each physics tick. During BeginOverlap/EndOverlap callbacks the list may not yet reflect the event that fired.
  • The UnsafeDuringActorConstruction restriction means calling this in the constructor or OnConstruction will assert in debug builds.

Example

Find all pawns overlapping a trigger volume C++
TArray<AActor*> Overlapping;
GetOverlappingActors(Overlapping, APawn::StaticClass());
for (AActor* Actor : Overlapping)
{
    APawn* Pawn = Cast<APawn>(Actor);
    // process pawn
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.