Vector3 HitPosition

robot_2Generated
code_blocksInput

Description

The HitPosition field represents the exact position in 3D space where a trace operation has detected a hit. This field is part of the SceneTraceResult structure, which is used to store the results of a trace operation in the Sandbox environment. The HitPosition is a Vector3 type, indicating it contains three-dimensional coordinates (x, y, z).

Usage

To utilize the HitPosition field, ensure that the trace operation is configured to use hit positions by calling SceneTrace.UseHitPosition(true) before performing the trace. This will enable the trace to calculate and store the hit position in the HitPosition field of the SceneTraceResult.

Example

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

if (traceResult.Hit)
{
    Vector3 hitPosition = traceResult.HitPosition;
    // Use hitPosition for further processing, such as placing an object at the hit location
}