UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FHitResult Struct Reference

#include <HitResult.h>

Public Member Functions

 FHitResult ()
 
 FHitResult (float InTime)
 
 FHitResult (EForceInit InInit)
 
 FHitResult (ENoInit NoInit)
 
 FHitResult (FVector Start, FVector End)
 
void Init ()
 
void Init (FVector Start, FVector End)
 
ENGINE_API FHitResult (AActor *InActor, UPrimitiveComponent *InComponent, FVector const &HitLoc, FVector const &HitNorm)
 
void Reset (float InTime=1.f, bool bPreserveTraceData=true)
 
AActorGetActor () const
 
FActorInstanceHandle GetHitObjectHandle () const
 
bool HasValidHitObjectHandle () const
 
UPrimitiveComponent * GetComponent () const
 
ENGINE_API bool NetSerialize (FArchive &Ar, UPackageMap *Map, bool &bOutSuccess)
 
bool IsValidBlockingHit () const
 
ENGINE_API FString ToString () const
 

Static Public Member Functions

static FHitResultGetFirstBlockingHit (TArray< FHitResult > &InHits)
 
static int32 GetNumBlockingHits (const TArray< FHitResult > &InHits)
 
static int32 GetNumOverlapHits (const TArray< FHitResult > &InHits)
 
static FHitResult GetReversedHit (const FHitResult &Hit)
 

Public Attributes

int32 FaceIndex
 
float Time
 
float Distance
 
FVector_NetQuantize Location
 
FVector_NetQuantize ImpactPoint
 
FVector_NetQuantizeNormal Normal
 
FVector_NetQuantizeNormal ImpactNormal
 
FVector_NetQuantize TraceStart
 
FVector_NetQuantize TraceEnd
 
float PenetrationDepth
 
int32 MyItem
 
int32 Item
 
uint8 ElementIndex
 
uint8 bBlockingHit: 1
 
uint8 bStartPenetrating: 1
 
TWeakObjectPtr< UPhysicalMaterialPhysMaterial
 
FActorInstanceHandle HitObjectHandle
 
TWeakObjectPtr< UPrimitiveComponent > Component
 
TWeakObjectPtr< UObjectPhysicsObjectOwner
 
Chaos::FPhysicsObjectHandle PhysicsObject
 
FName BoneName
 
FName MyBoneName
 

Detailed Description

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

Constructor & Destructor Documentation

◆ FHitResult() [1/6]

FHitResult::FHitResult ( )
inline

◆ FHitResult() [2/6]

FHitResult::FHitResult ( float  InTime)
inlineexplicit

◆ FHitResult() [3/6]

FHitResult::FHitResult ( EForceInit  InInit)
inlineexplicit

◆ FHitResult() [4/6]

FHitResult::FHitResult ( ENoInit  NoInit)
inlineexplicit

◆ FHitResult() [5/6]

FHitResult::FHitResult ( FVector  Start,
FVector  End 
)
inlineexplicit

◆ FHitResult() [6/6]

FHitResult::FHitResult ( AActor InActor,
UPrimitiveComponent *  InComponent,
FVector const &  HitLoc,
FVector const &  HitNorm 
)

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

Member Function Documentation

◆ GetActor()

AActor * FHitResult::GetActor ( ) const
inline

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

◆ GetComponent()

UPrimitiveComponent * FHitResult::GetComponent ( ) const
inline

Utility to return the Component that was hit.

◆ GetFirstBlockingHit()

static FHitResult * FHitResult::GetFirstBlockingHit ( TArray< FHitResult > &  InHits)
inlinestatic

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

◆ GetHitObjectHandle()

FActorInstanceHandle FHitResult::GetHitObjectHandle ( ) const
inline

◆ GetNumBlockingHits()

static int32 FHitResult::GetNumBlockingHits ( const TArray< FHitResult > &  InHits)
inlinestatic

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

◆ GetNumOverlapHits()

static int32 FHitResult::GetNumOverlapHits ( const TArray< FHitResult > &  InHits)
inlinestatic

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

◆ GetReversedHit()

static FHitResult FHitResult::GetReversedHit ( const FHitResult Hit)
inlinestatic

Get a copy of the HitResult with relevant information reversed. For example when receiving a hit from another object, we reverse the normals.

◆ HasValidHitObjectHandle()

bool FHitResult::HasValidHitObjectHandle ( ) const
inline

◆ Init() [1/2]

void FHitResult::Init ( )
inline

Initialize empty hit result with given time.

◆ Init() [2/2]

void FHitResult::Init ( FVector  Start,
FVector  End 
)
inline

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

◆ IsValidBlockingHit()

bool FHitResult::IsValidBlockingHit ( ) const
inline

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

◆ NetSerialize()

bool FHitResult::NetSerialize ( FArchive Ar,
UPackageMap Map,
bool bOutSuccess 
)

Optimized serialize function

◆ Reset()

void FHitResult::Reset ( float  InTime = 1.f,
bool  bPreserveTraceData = true 
)
inline

Reset hit result while optionally saving TraceStart and TraceEnd.

◆ ToString()

FString FHitResult::ToString ( ) const

Member Data Documentation

◆ bBlockingHit

uint8 FHitResult::bBlockingHit

Indicates if this hit was a result of blocking collision. If false, there was no hit or it was an overlap/touch instead.

◆ BoneName

FName FHitResult::BoneName

Name of bone we hit (for skeletal meshes).

◆ bStartPenetrating

uint8 FHitResult::bStartPenetrating

Whether the trace started in penetration, i.e. with an initial blocking overlap. In the case of penetration, if PenetrationDepth > 0.f, then it will represent the distance along the Normal vector that will result in minimal contact between the swept shape and the object that was hit. In this case, ImpactNormal will be the normal opposed to movement at that location (ie, Normal may not equal ImpactNormal). ImpactPoint will be the same as Location, since there is no single impact point to report.

◆ Component

TWeakObjectPtr<UPrimitiveComponent> FHitResult::Component

PrimitiveComponent hit by the trace.

◆ Distance

float FHitResult::Distance

The distance from the TraceStart to the Location in world space. This value is 0 if there was an initial overlap (trace started inside another colliding object).

◆ ElementIndex

uint8 FHitResult::ElementIndex

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

◆ FaceIndex

int32 FHitResult::FaceIndex

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

◆ HitObjectHandle

FActorInstanceHandle FHitResult::HitObjectHandle

Handle to the object hit by the trace.

◆ ImpactNormal

FVector_NetQuantizeNormal FHitResult::ImpactNormal

Normal of the hit in world space, for the object that was hit by the sweep, if any. For example if a sphere hits a flat plane, this is a normalized vector pointing out from the plane. In the case of impact with a corner or edge of a surface, usually the "most opposing" normal (opposed to the query direction) is chosen.

◆ ImpactPoint

FVector_NetQuantize FHitResult::ImpactPoint

Location in world space of the actual contact of the trace shape (box, sphere, ray, etc) with the impacted object. Example: for a sphere trace test, this is the point where the surface of the sphere touches the other object.

Note
: In the case of initial overlap (bStartPenetrating=true), ImpactPoint will be the same as Location because there is no meaningful single impact point to report.

◆ Item

int32 FHitResult::Item

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

◆ Location

FVector_NetQuantize FHitResult::Location

The location in world space where the moving shape would end up against the impacted object, if there is a hit. Equal to the point of impact for line tests. Example: for a sphere trace test, this is the point where the center of the sphere would be located when it touched the other object. For swept movement (but not queries) this may not equal the final location of the shape since hits are pulled back slightly to prevent precision issues from overlapping another surface.

◆ MyBoneName

FName FHitResult::MyBoneName

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

◆ MyItem

int32 FHitResult::MyItem

If the hit result is from a collision this will have extra info about the item that hit the second item.

◆ Normal

FVector_NetQuantizeNormal FHitResult::Normal

Normal of the hit in world space, for the object that was swept. Equal to ImpactNormal for line tests. This is computed for capsules and spheres, otherwise it will be the same as ImpactNormal. Example: for a sphere trace test, this is a normalized vector pointing in towards the center of the sphere at the point of impact.

◆ PenetrationDepth

float FHitResult::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. If the distance cannot be computed, this distance will be zero.

◆ PhysicsObject

Chaos::FPhysicsObjectHandle FHitResult::PhysicsObject

PhysicsObjects hit by the query. Not exposed to blueprints for the time being

◆ PhysicsObjectOwner

TWeakObjectPtr<UObject> FHitResult::PhysicsObjectOwner

The object that owns the PhysicsObject. This is used to determine if the PhysicsObject is still valid when not owned by an Actor

◆ PhysMaterial

TWeakObjectPtr<UPhysicalMaterial> FHitResult::PhysMaterial

Physical material that was hit.

Note
Must set bReturnPhysicalMaterial on the swept PrimitiveComponent or in the query params for this to be returned.

◆ Time

float FHitResult::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. For swept movement (but not queries) this may be pulled back slightly from the actual time of impact, to prevent precision problems with adjacent geometry.

◆ TraceEnd

FVector_NetQuantize FHitResult::TraceEnd

End location of the trace; this is NOT where the impact occurred (if any), but the furthest point in the attempted sweep. For example if a sphere is swept against the world, this would be the center of the sphere if there was no blocking hit.

◆ TraceStart

FVector_NetQuantize FHitResult::TraceStart

Start location of the trace. For example if a sphere is swept against the world, this is the starting location of the center of the sphere.


The documentation for this struct was generated from the following files: