UKismetSystemLibrary::SphereOverlapComponents
#include "Kismet/KismetSystemLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintCallable
Description
Finds every primitive component whose collision overlaps the given world-space sphere. Filters can restrict results by Object Type and by component class.
Caveats & Gotchas
- • Converts each entry in ObjectTypes to a collision channel via UCollisionProfile::ConvertToCollisionChannel and queries with OverlapMultiByObjectType — an empty ObjectTypes array matches nothing and always returns false.
- • This is an instantaneous overlap test at a fixed SpherePos, not a sweep between two points — use SphereTraceSingle if you need swept collision along a path.
Signature
static ENGINE_API bool SphereOverlapComponents(const UObject* WorldContextObject, const FVector SpherePos, float SphereRadius, const TArray<TEnumAsByte<EObjectTypeQuery> > & ObjectTypes, UClass* ComponentClassFilter, const TArray<AActor*>& ActorsToIgnore, TArray<class UPrimitiveComponent*>& OutComponents) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| WorldContextObject | const UObject* | Object used to resolve which UWorld to run the query in. | — |
| SpherePos | const FVector | Center of the sphere in world space. | — |
| SphereRadius | float | Radius of the sphere. | — |
| ObjectTypes | const TArray<TEnumAsByte<EObjectTypeQuery> >& | Object Types (Project Settings > Collision) to restrict the query to. | — |
| ComponentClassFilter | UClass* | If set, only components of this class or subclasses are returned. | — |
| ActorsToIgnore | const TArray<AActor*>& | Actors whose components are excluded from the results. | — |
| OutComponents | TArray<UPrimitiveComponent*>& | Returned array of overlapping components. Unsorted. | — |
Return Type
bool Example
Find overlapping components in a radius C++
TArray<TEnumAsByte<EObjectTypeQuery>> ObjectTypes;
ObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECC_WorldDynamic));
TArray<AActor*> ActorsToIgnore;
ActorsToIgnore.Add(this);
TArray<UPrimitiveComponent*> OverlappingComponents;
UKismetSystemLibrary::SphereOverlapComponents(this, GetActorLocation(), 300.f, ObjectTypes, nullptr, ActorsToIgnore, OverlappingComponents); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?