engine
 
载入中...
搜索中...
未找到
Public 成员函数 | 静态 Public 成员函数 | Public 属性 | 所有成员列表
FHitResult结构体 参考

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

#include <EngineTypes.h>

Public 成员函数

 FHitResult (class AActor *InActor, class UPrimitiveComponent *InComponent, FVector const &HitLoc, FVector const &HitNorm)
 Ctor for easily creating "fake" hits from limited data.
 
FORCEINLINE AActor * GetActor () const
 Utility to return the Actor that owns the Component that was hit.
 
FORCEINLINE UPrimitiveComponent * GetComponent () const
 Utility to return the Component that was hit.
 
FORCEINLINE void Init ()
 Initialize empty hit result with given time.
 
FORCEINLINE void Init (FVector Start, FVector End)
 Initialize empty hit result with given time, TraceStart, and TraceEnd
 
FORCEINLINE bool IsValidBlockingHit () const
 Return true if there was a blocking hit that was not caused by starting in penetration.
 
bool NetSerialize (FArchive &Ar, class UPackageMap *Map, bool &bOutSuccess)
 Optimized serialize function
 
FORCEINLINE void Reset (float InTime=1.f, bool bPreserveTraceData=true)
 Reset hit result while optionally saving TraceStart and TraceEnd.
 

静态 Public 成员函数

static FHitResult * GetFirstBlockingHit (TArray< FHitResult > &InHits)
 Static utility function that returns the first 'blocking' hit in an array of results.
 
static int32 GetNumBlockingHits (const TArray< FHitResult > &InHits)
 Static utility function that returns the number of blocking hits in array.
 
static int32 GetNumOverlapHits (const TArray< FHitResult > &InHits)
 Static utility function that returns the number of overlapping hits in array.
 
static FHitResult GetReversedHit (const FHitResult &Hit)
 Get a copy of the HitResult with relevant information reversed. 更多...
 

Public 属性

TWeakObjectPtr< class AActor > Actor
 Actor hit by the trace.
 
uint8 bBlockingHit:1
 Indicates if this hit was a result of blocking collision. 更多...
 
FName BoneName
 Name of bone we hit (for skeletal meshes).
 
uint8 bStartPenetrating:1
 Whether the trace started in penetration, i.e. 更多...
 
TWeakObjectPtr< class UPrimitiveComponent > Component
 PrimitiveComponent hit by the trace.
 
float Distance
 The distance from the TraceStart to the Location in world space. 更多...
 
uint8 ElementIndex
 Index to item that was hit, also hit primitive specific.
 
int32 FaceIndex
 Face index we hit (for complex hits with triangle meshes).
 
FVector_NetQuantizeNormal ImpactNormal
 Normal of the hit in world space, for the object that was hit by the sweep, if any. 更多...
 
FVector_NetQuantize ImpactPoint
 Location in world space of the actual contact of the trace shape (box, sphere, ray, etc) with the impacted object. 更多...
 
int32 Item
 Extra data about item that was hit (hit primitive specific).
 
FVector_NetQuantize Location
 The location in world space where the moving shape would end up against the impacted object, if there is a hit. 更多...
 
FName MyBoneName
 Name of the my bone which took part in hit event (in case of two skeletal meshes colliding).
 
FVector_NetQuantizeNormal Normal
 Normal of the hit in world space, for the object that was swept. 更多...
 
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. 更多...
 
TWeakObjectPtr< class UPhysicalMaterial > PhysMaterial
 Physical material that was hit. 更多...
 
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. 更多...
 
FVector_NetQuantize TraceEnd
 End location of the trace; this is NOT where the impact occurred (if any), but the furthest point in the attempted sweep. 更多...
 
FVector_NetQuantize TraceStart
 Start location of the trace. 更多...
 

详细描述

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

成员函数说明

◆ 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.

类成员变量说明

◆ 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.

◆ 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.

◆ 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).

◆ 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.

注解
: 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.

◆ 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.

◆ 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.

◆ PhysMaterial

TWeakObjectPtr<class UPhysicalMaterial> FHitResult::PhysMaterial

Physical material that was hit.

注解
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.


该结构体的文档由以下文件生成: