RealDocs

UGameplayStatics::MakeHitResult

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

Description

Constructs an FHitResult from individual fields. Primarily a Blueprint utility ('Make Hit Result' node) for manually crafting hit results in testing or procedural scenarios.

Caveats & Gotchas

  • Manually constructed FHitResults bypass the usual collision query pipeline; passing them to systems that assume the data came from a real query (e.g. physics damage handlers) may produce unexpected behaviour.
  • In C++ it is almost always clearer to construct FHitResult directly and assign members by name rather than calling this function.

Signature

static ENGINE_API FHitResult MakeHitResult(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
bBlockingHit bool Whether this represents a blocking hit.
bInitialOverlap bool Whether the trace started inside the hit object.
Time float Normalized [0,1] hit time along the trace.
Distance float World-space distance to the hit location.
Location FVector Safe placement location for the swept shape.
ImpactPoint FVector Exact contact point on the surface.
Normal FVector Normal of the swept shape at impact.
ImpactNormal FVector Normal of the hit surface.
PhysMat class UPhysicalMaterial* Physical material at the hit surface.
HitActor class AActor* Actor that was hit.
HitComponent class UPrimitiveComponent* Component that was hit.
HitBoneName FName Bone name on a hit skeletal mesh.
BoneName FName Trace bone name on the swept skeletal mesh.
HitItem int32 Primitive-specific item index.
ElementIndex int32 Element/section index on the hit primitive.
FaceIndex int32 Triangle face index for trimesh or landscape hits.
TraceStart FVector Start of the originating trace.
TraceEnd FVector End of the originating trace.

Return Type

FHitResult

Example

Construct a synthetic hit for testing damage C++
// Build a fake HitResult pointing straight down for unit testing.
FHitResult FakeHit = UGameplayStatics::MakeHitResult(
    true, false, 0.5f, 100.f,
    FVector(0,0,50), FVector(0,0,50),
    FVector(0,0,1), FVector(0,0,1),
    nullptr, TargetActor, TargetComp,
    NAME_None, NAME_None, 0, 0, 0,
    FVector(0,0,150), FVector(0,0,-100));

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.