Description
The Fraction
field in the PhysicsTraceResult
struct represents the fraction of the distance between the start and end positions where the trace hit an object. It is a floating-point value ranging from 0 to 1, where 0 indicates the trace hit immediately at the start position, and 1 indicates the trace reached the end position without hitting anything.
Usage
Use the Fraction
field to determine how far along the trace path an intersection occurred. This can be useful for calculating the exact point of impact or for determining if an object was hit early or late in the trace.
Example
PhysicsTraceResult traceResult = PerformTrace();
if (traceResult.Hit)
{
float hitFraction = traceResult.Fraction;
Vector3 hitPoint = traceResult.StartPosition + (traceResult.Direction * hitFraction * traceResult.Distance);
// Use hitPoint for further calculations or logic
}