book_4_sparkGenerated
code_blocksInput

Description

The Run method of the MeshTraceRequest struct executes the ray tracing operation and returns the result of the trace. This method is designed to return the first hit encountered during the trace operation.

Usage

To use the Run method, you must first create an instance of MeshTraceRequest and configure it with the desired parameters, such as the ray's origin and direction. Once configured, call the Run method to perform the trace and obtain the result.

Example

// Example of using MeshTraceRequest to perform a ray trace

// Define the start and end points of the ray
Vector3 startPoint = new Vector3(0, 0, 0);
Vector3 endPoint = new Vector3(10, 0, 0);

// Create a MeshTraceRequest
MeshTraceRequest traceRequest = new MeshTraceRequest();

// Configure the trace request with the ray
traceRequest = traceRequest.Ray(ref startPoint, ref endPoint);

// Run the trace
MeshTraceRequest.Result result = traceRequest.Run();

// Check if the trace hit something
if (result.Hit)
{
    // Process the hit result
    Console.WriteLine($"Hit at position: {result.Position}");
}