![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#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) |
| AActor * | GetActor () 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 FHitResult * | GetFirstBlockingHit (TArray< FHitResult > &InHits) |
| static int32 | GetNumBlockingHits (const TArray< FHitResult > &InHits) |
| static int32 | GetNumOverlapHits (const TArray< FHitResult > &InHits) |
| static FHitResult | GetReversedHit (const FHitResult &Hit) |
Structure containing information about one hit of a trace, such as point of impact and surface normal at that point.
|
inline |
|
inlineexplicit |
|
inlineexplicit |
|
inlineexplicit |
| FHitResult::FHitResult | ( | AActor * | InActor, |
| UPrimitiveComponent * | InComponent, | ||
| FVector const & | HitLoc, | ||
| FVector const & | HitNorm | ||
| ) |
Ctor for easily creating "fake" hits from limited data.
|
inline |
Utility to return the Actor that owns the Component that was hit.
|
inline |
Utility to return the Component that was hit.
|
inlinestatic |
Static utility function that returns the first 'blocking' hit in an array of results.
|
inline |
|
inlinestatic |
Static utility function that returns the number of blocking hits in array.
|
inlinestatic |
Static utility function that returns the number of overlapping hits in array.
|
inlinestatic |
Get a copy of the HitResult with relevant information reversed. For example when receiving a hit from another object, we reverse the normals.
|
inline |
|
inline |
Initialize empty hit result with given time.
Initialize empty hit result with given time, TraceStart, and TraceEnd
|
inline |
Return true if there was a blocking hit that was not caused by starting in penetration.
| bool FHitResult::NetSerialize | ( | FArchive & | Ar, |
| UPackageMap * | Map, | ||
| bool & | bOutSuccess | ||
| ) |
Optimized serialize function
Reset hit result while optionally saving TraceStart and TraceEnd.
| FString FHitResult::ToString | ( | ) | const |
| 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.
| FName FHitResult::BoneName |
Name of bone we hit (for skeletal meshes).
| 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.
| TWeakObjectPtr<UPrimitiveComponent> FHitResult::Component |
PrimitiveComponent hit by the trace.
| 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).
| uint8 FHitResult::ElementIndex |
Index to item that was hit, also hit primitive specific.
| int32 FHitResult::FaceIndex |
Face index we hit (for complex hits with triangle meshes).
| FActorInstanceHandle FHitResult::HitObjectHandle |
Handle to the object hit by the trace.
| 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.
| 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.
| int32 FHitResult::Item |
Extra data about item that was hit (hit primitive specific).
| 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.
| FName FHitResult::MyBoneName |
Name of the my bone which took part in hit event (in case of two skeletal meshes colliding).
| int32 FHitResult::MyItem |
If the hit result is from a collision this will have extra info about the item that hit the second item.
| 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.
| 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.
| Chaos::FPhysicsObjectHandle FHitResult::PhysicsObject |
PhysicsObjects hit by the query. Not exposed to blueprints for the time being
| 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
| TWeakObjectPtr<UPhysicalMaterial> FHitResult::PhysMaterial |
Physical material that was hit.
| 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.
| 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.
| 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.