FHitResult

Structure containing information about one hit of a trace, such as point of impact and surface normal at that point.

Windows
MacOS
Linux

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/Engine/EngineTypes.h

Include

#include "Engine/EngineTypes.h"

Syntax

struct FHitResult

Remarks

Structure containing information about one hit of a trace, such as point of impact and surface normal at that point.

Variables

Name Description

Public variable

TWeakObjectPtr<...

 

Actor

Actor hit by the trace.

Public variable

uint8: 1

 

bBlockingHit

Indicates if this hit was a result of blocking collision.

Public variable

FName

 

BoneName

Name of bone we hit (for skeletal meshes).

Public variable

uint8: 1

 

bStartPenetrating

Whether the trace started in penetration, i.e. with an initial blocking overlap.

Public variable

TWeakObjectPtr<...

 

Component

PrimitiveComponent hit by the trace.

Public variable

float

 

Distance

The distance from the TraceStart to the Location in world space.

Public variable

uint8

 

ElementIndex

Index to item that was hit, also hit primitive specific.

Public variable

int32

 

FaceIndex

Face index we hit (for complex hits with triangle meshes).

Public variable

FVector_NetQuan...

 

ImpactNormal

Normal of the hit in world space, for the object that was hit by the sweep, if any.

Public variable

FVector_NetQuan...

 

ImpactPoint

Location in world space of the actual contact of the trace shape (box, sphere, ray, etc) with the impacted object.

Public variable

int32

 

Item

Extra data about item that was hit (hit primitive specific).

Public variable

FVector_NetQuan...

 

Location

The location in world space where the moving shape would end up against the impacted object, if there is a hit.

Public variable

FName

 

MyBoneName

Name of the my bone which took part in hit event (in case of two skeletal meshes colliding).

Public variable

FVector_NetQuan...

 

Normal

Normal of the hit in world space, for the object that was swept.

Public variable

float

 

PenetrationDepth

If this test started in penetration (bStartPenetrating is true) and a depenetration vector can be computed, this value is the distance along Normal that will result in moving out of penetration.

Public variable

TWeakObjectPtr<...

 

PhysMaterial

Physical material that was hit.

Public variable

float

 

Time

'Time' of impact along trace direction (ranging from 0.0 to 1.0) if there is a hit, indicating time between TraceStart and TraceEnd.

Public variable

FVector_NetQuan...

 

TraceEnd

End location of the trace; this is NOT where the impact occurred (if any), but the furthest point in the attempted sweep.

Public variable

FVector_NetQuan...

 

TraceStart

Start location of the trace.

Constructors

Name Description

Public function

FHitResult()

Public function

FHitResult

(
    float InTime
)

Public function

FHitResult

(
    EForceInit InInit
)

Public function

FHitResult

(
    ENoInit NoInit
)

Public function

FHitResult

(
    FVector Start,
    FVector End
)

Public function

FHitResult

(
    AActor* InActor,
    UPrimitiveComponent* InCompone...,
    FVector const& HitLoc,
    FVector const& HitNorm
)

Ctor for easily creating "fake" hits from limited data.

Functions

Name Description

Public function Const

AActor *

 

GetActor()

Utility to return the Actor that owns the Component that was hit.

Public function Const

UPrimitiveCo...

 

GetComponent()

Utility to return the Component that was hit.

Public function Static

FHitResult &...

 

GetFirstBlockingHit

(
    TArray< FHitResult >& InHits
)

Static utility function that returns the first 'blocking' hit in an array of results.

Public function Static

int32

 

GetNumBlockingHits

(
    const TArray< FHitResult >& InHits
)

Static utility function that returns the number of blocking hits in array.

Public function Static

int32

 

GetNumOverlapHits

(
    const TArray< FHitResult >& InHits
)

Static utility function that returns the number of overlapping hits in array.

Public function Static

FHitResult

 

GetReversedHit

(
    const FHitResult& Hit
)

Get a copy of the HitResult with relevant information reversed.

Public function

void

 

Init

(
    FVector Start,
    FVector End
)

Initialize empty hit result with given time, TraceStart, and TraceEnd

Public function

void

 

Init()

Initialize empty hit result with given time.

Public function Const

bool

 

IsValidBlockingHit()

Return true if there was a blocking hit that was not caused by starting in penetration.

Public function

bool

 

NetSerialize

(
    FArchive& Ar,
    UPackageMap* Map,
    bool& bOutSuccess
)

Optimized serialize function

Public function

void

 

Reset

(
    float InTime,
    bool bPreserveTraceData
)

Reset hit result while optionally saving TraceStart and TraceEnd.

Public function Const

FString

 

ToString()

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss