float Fraction

robot_2Generated
code_blocksInput

Description

The Fraction field in the SceneTraceResult struct represents the fraction of the distance from the start to the end of a trace where a hit occurred. It is a floating-point value ranging from 0 to 1, where 0 indicates the hit occurred at the start position, and 1 indicates the hit occurred at the end position.

Usage

Use the Fraction field to determine how far along the trace path a hit was detected. This can be useful for calculating the exact position of the hit or for determining if the hit occurred closer to the start or end of the trace.

Example

// Example usage of SceneTraceResult.Fraction
SceneTraceResult traceResult = SceneTraceResult.From(scene, trace);

if (traceResult.Hit)
{
    float hitFraction = traceResult.Fraction;
    Vector3 hitPosition = Vector3.Lerp(traceResult.StartPosition, traceResult.EndPosition, hitFraction);
    // Use hitPosition for further processing
}