UWorld::SweepMultiByProfile
#include "Engine/World.h"
Access: public
Specifiers: const
Description
Sweeps a collision shape from Start to End using a named collision profile and returns all hits. Useful when you want sweep behaviour that mirrors a specific actor's collision preset without manually specifying channels and responses.
Caveats & Gotchas
- • ProfileName must exactly match a profile defined in Project Settings → Collision. An invalid name triggers an ensure() and the query falls back to blocking everything — verify profile names with UCollisionProfile::Get()->GetProfileByIndex().
- • Returns true only if OutHits contains a blocking hit. A sweep that finds overlaps but no blocking hit returns false.
- • Results are sorted: overlaps first, first blocking hit last. Only one blocking hit is ever returned.
Signature
bool SweepMultiByProfile(TArray<FHitResult>& OutHits, const FVector& Start, const FVector& End, const FQuat& Rot, FName ProfileName, const FCollisionShape& CollisionShape, const FCollisionQueryParams& Params = FCollisionQueryParams::DefaultQueryParam) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| OutHits | TArray<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. | — |
| ProfileName | FName | Name of the collision profile to use, as defined in Project Settings → Collision. | — |
| 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
Box sweep using the Pawn collision profile C++
TArray<FHitResult> Hits;
FCollisionShape Box = FCollisionShape::MakeBox(FVector(50.f, 50.f, 88.f));
FCollisionQueryParams Params;
Params.AddIgnoredActor(this);
bool bBlocked = GetWorld()->SweepMultiByProfile(
Hits,
GetActorLocation(),
GetActorLocation() + FVector(0.f, 0.f, -200.f),
FQuat::Identity,
FName(TEXT("Pawn")),
Box,
Params
);
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?