Vector3 HitPosition

book_4_sparkGenerated
code_blocksInput

Description

The HitPosition field of the SceneTraceResult struct represents the exact position in 3D space where a trace operation has hit an object within the scene. This field is of type Vector3, which is a structure that holds three-dimensional coordinates (x, y, z).

Usage

Use the HitPosition field to determine the precise location of a hit during a trace operation. This can be useful for various applications such as collision detection, placing objects at the point of impact, or calculating the distance from the hit point to another point in space.

Example

// Example of using HitPosition in a trace operation
SceneTraceResult traceResult = SceneTraceResult.From(scene, ref physicsTraceResult);

if (traceResult.Hit)
{
    Vector3 hitPosition = traceResult.HitPosition;
    // Use hitPosition for further processing
    // For example, spawn an effect at the hit position
    SpawnEffectAtPosition(hitPosition);
}