RealDocs

UGameplayStatics::BreakHitResult

function Engine Blueprint Since 4.0
#include "Kismet/GameplayStatics.h"
Access: public Specifiers: staticUFUNCTIONBlueprintPure

Description

Decomposes an FHitResult struct into its individual fields. In Blueprint this is the 'Break Hit Result' node; in C++ prefer accessing FHitResult members directly for better readability.

Caveats & Gotchas

  • PhysMat is nullptr unless the query that produced the hit had bReturnPhysicalMaterial set to true — check for null before dereferencing.
  • When bInitialOverlap is true, Time equals 0, ImpactPoint equals Location, and Normal equals ImpactNormal — the values indicate depenetration direction, not a real surface hit.

Signature

static ENGINE_API void BreakHitResult(const struct FHitResult& Hit, bool& bBlockingHit, bool& bInitialOverlap, float& Time, float& Distance, FVector& Location, FVector& ImpactPoint, FVector& Normal, FVector& ImpactNormal, class UPhysicalMaterial*& PhysMat, class AActor*& HitActor, class UPrimitiveComponent*& HitComponent, FName& HitBoneName, FName& BoneName, int32& HitItem, int32& ElementIndex, int32& FaceIndex, FVector& TraceStart, FVector& TraceEnd);

Parameters

Name Type Description Default
Hit const struct FHitResult& The FHitResult struct to decompose.
bBlockingHit bool& True if the trace produced a blocking (not overlap) hit.
bInitialOverlap bool& True if the trace started inside the hit object.
Time float& Normalized [0,1] distance along the trace where the hit occurred.
Distance float& World-space distance from TraceStart to Location.
Location FVector& Point where the swept shape can be placed without penetrating the hit object.
ImpactPoint FVector& Exact contact point on the surface.
Normal FVector& Normal of the swept shape at the hit point (sphere center direction for sphere traces).
ImpactNormal FVector& Normal of the hit surface.
PhysMat class UPhysicalMaterial*& Physical material at the hit surface; nullptr unless bReturnPhysicalMaterial was set in the query.
HitActor class AActor*& Actor that was hit.
HitComponent class UPrimitiveComponent*& Primitive component that was hit.
HitBoneName FName& Bone name on the hit skeletal mesh, if applicable.
BoneName FName& Trace bone hit on the swept skeletal mesh, if applicable.
HitItem int32& Primitive-specific hit item index.
ElementIndex int32& Element/section index on the hit primitive, for multi-material meshes.
FaceIndex int32& Triangle face index, valid for trimesh and landscape hits.
TraceStart FVector& The start of the original trace.
TraceEnd FVector& The end of the original trace.

Return Type

void

Example

Extract actor and impact point from a hit C++
// In C++ you can read FHitResult directly, but BreakHitResult is the Blueprint equivalent.
bool bBlocking, bInitOverlap;
float Time, Dist;
FVector Loc, ImpPt, Normal, ImpNormal, TStart, TEnd;
UPhysicalMaterial* PhysMat;
AActor* HitActor;
UPrimitiveComponent* HitComp;
FName HitBone, Bone;
int32 Item, ElemIdx, FaceIdx;
UGameplayStatics::BreakHitResult(HitResult, bBlocking, bInitOverlap, Time, Dist,
    Loc, ImpPt, Normal, ImpNormal, PhysMat,
    HitActor, HitComp, HitBone, Bone, Item, ElemIdx, FaceIdx, TStart, TEnd);

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.