UKismetSystemLibrary::CapsuleTraceMultiForObjects
#include "Kismet/KismetSystemLibrary.h"
Access: public
Specifiers: staticBlueprintCallable
Description
Sweeps a capsule from Start to End and returns every hit against components whose collision responds to one of the given Object Types. Exposed to Blueprint as 'Multi Capsule Trace For Objects'.
Caveats & Gotchas
- • This is the combination most commonly used for melee hit detection against multiple enemies — sweep a capsule along the weapon's path with ObjectTypes set to Pawn.
- • Because there's no blocking-hit concept for Object Type queries, a capsule that fully overlaps several actors at once will return all of them from a single call, unlike CapsuleTraceMulti's channel-based blocking semantics.
- • HalfHeight and Radius define the same shape as CapsuleTraceMulti; only the filtering model (Object Type vs Trace Channel) differs between the two functions.
Signature
static ENGINE_API bool CapsuleTraceMultiForObjects(const UObject* WorldContextObject, const FVector Start, const FVector End, float Radius, float HalfHeight, const TArray<TEnumAsByte<EObjectTypeQuery> > & ObjectTypes, bool bTraceComplex, const TArray<AActor*>& ActorsToIgnore, EDrawDebugTrace::Type DrawDebugType, TArray<FHitResult>& OutHits, bool bIgnoreSelf, FLinearColor TraceColor = FLinearColor::Red, FLinearColor TraceHitColor = FLinearColor::Green, float DrawTime = 5.0f) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| WorldContextObject | const UObject* | World context. | — |
| Start | const FVector | Start of the sweep. | — |
| End | const FVector | End of the sweep. | — |
| Radius | float | Radius of the capsule to sweep. | — |
| HalfHeight | float | Distance from the center of the capsule to the tip of a hemisphere endcap. | — |
| ObjectTypes | const TArray<TEnumAsByte<EObjectTypeQuery>>& | Array of Object Types to trace against. | — |
| bTraceComplex | bool | True to test against complex collision, false to test against simplified collision. | — |
| ActorsToIgnore | const TArray<AActor*>& | Actors to exclude from the trace. | — |
| DrawDebugType | EDrawDebugTrace::Type | Debug draw mode. | — |
| OutHits | TArray<FHitResult>& | All hits found along the sweep. | — |
| bIgnoreSelf | bool | Whether to ignore the world context actor itself. | — |
| TraceColor | FLinearColor | Debug draw color for the trace. | FLinearColor::Red |
| TraceHitColor | FLinearColor | Debug draw color for hits. | FLinearColor::Green |
| DrawTime | float | How long the debug draw persists, in seconds. | 5.0f |
Return Type
bool Example
Sweep a capsule along a melee weapon's swing to hit all pawns C++
TArray<FHitResult> Hits;
TArray<TEnumAsByte<EObjectTypeQuery>> ObjectTypes;
ObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECC_Pawn));
TArray<AActor*> ActorsToIgnore;
ActorsToIgnore.Add(this);
const FVector Start = WeaponStartLocation;
const FVector End = WeaponEndLocation;
bool bHit = UKismetSystemLibrary::CapsuleTraceMultiForObjects(this, Start, End, 20.f, 60.f, ObjectTypes, false, ActorsToIgnore, EDrawDebugTrace::ForDuration, Hits, true); See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?