UWorld::SweepMultiByObjectType
#include "Engine/World.h"
Access: public
Specifiers: const
Description
Sweeps a collision shape from Start to End and returns all hits against objects of the specified physical object types. Use this when you want to match by object type (WorldStatic, Pawn, etc.) rather than a trace channel.
Caveats & Gotchas
- • Returns true if any hit was found — unlike SweepMultiByChannel which returns true only if a blocking hit exists. Check FHitResult.bBlockingHit per entry to distinguish overlaps from blocks.
- • FCollisionObjectQueryParams can combine multiple object types in one query. Construct it with FCollisionObjectQueryParams(ECC_TO_BITFIELD(ECC_WorldStatic) | ECC_TO_BITFIELD(ECC_Pawn)) or use the convenience constructor that takes a single ECollisionChannel.
- • Results are sorted: overlaps first, blocking hit last. All blocking hits are returned unlike SweepMultiByChannel.
Signature
bool SweepMultiByObjectType(TArray<struct FHitResult>& OutHits, const FVector& Start, const FVector& End, const FQuat& Rot, const FCollisionObjectQueryParams& ObjectQueryParams, const FCollisionShape& CollisionShape, const FCollisionQueryParams& Params = FCollisionQueryParams::DefaultQueryParam) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| OutHits | TArray<struct FHitResult>& | Array populated with all hits found during the sweep. | — |
| Start | const FVector& | World-space start location of the shape. | — |
| End | const FVector& | World-space end location of the shape. | — |
| Rot | const FQuat& | Rotation of the shape, held constant throughout the sweep. | — |
| ObjectQueryParams | const FCollisionObjectQueryParams& | Specifies which physical object types (e.g. WorldStatic, Pawn) to include in the query. | — |
| CollisionShape | const FCollisionShape& | The shape to sweep — supports Box, Sphere, or Capsule. | — |
| Params | const FCollisionQueryParams& | Additional query parameters such as actors to ignore. | FCollisionQueryParams::DefaultQueryParam |
Return Type
bool Example
Sphere sweep against Pawns and WorldStatic C++
TArray<FHitResult> Hits;
FCollisionObjectQueryParams ObjectParams(
ECC_TO_BITFIELD(ECC_WorldStatic) | ECC_TO_BITFIELD(ECC_Pawn)
);
FCollisionShape Sphere = FCollisionShape::MakeSphere(100.f);
bool bHit = GetWorld()->SweepMultiByObjectType(
Hits,
StartLocation,
EndLocation,
FQuat::Identity,
ObjectParams,
Sphere
);
for (const FHitResult& Hit : Hits)
{
// process each hit
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?