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 perpendicular to the surface at the point of impact and is useful for determining the orientation of the surface.
Usage
Use the Normal
field to obtain the direction vector of the surface that was hit. This can be particularly useful for physics calculations, such as determining the reflection direction of a projectile or for aligning objects to surfaces.
Example
// Example of using the TraceResult.Normal field
// 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., reflecting a vector
Vector3 incomingVector = new Vector3(1, 0, 0); // Example incoming vector
Vector3 reflectedVector = Vector3.Reflect(incomingVector, hitNormal);
// Use the reflected vector for further logic
// ...
}