Vector3 Normal

book_4_sparkGenerated
code_blocksInput

Description

The Normal field of the TraceResult struct represents the normal vector of the surface that was hit during a trace operation. This vector is a unit vector that is perpendicular to the surface at the point of impact, indicating the direction in which the surface is facing.

Usage

Use the Normal field to determine the orientation of the surface that was hit by a trace. This can be useful for calculating reflections, determining surface alignment, or applying physics-based responses to collisions.

Example

// Example usage of TraceResult.Normal

// Assume we have a TraceResult object from a trace operation
TraceResult traceResult = PerformTrace();

// Check if the trace hit something
if (traceResult.Hit)
{
    // Get the normal of the hit surface
    Vector3 hitNormal = traceResult.Normal;
    
    // Use the normal for further calculations, e.g., reflection
    Vector3 incomingDirection = new Vector3(1, 0, 0); // Example incoming direction
    Vector3 reflectionDirection = Vector3.Reflect(incomingDirection, hitNormal);
    
    // Use reflectionDirection for further logic
}