The Run
method executes the mesh trace request and returns the result of the trace. This method is designed to return the first hit encountered during the trace operation.
The Run
method executes the mesh trace request and returns the result of the trace. This method is designed to return the first hit encountered during the trace operation.
To use the Run
method, you must first configure a MeshTraceRequest
with the desired parameters, such as the ray direction and any tags to include or exclude. Once configured, call the Run
method to perform the trace and obtain the result.
// Example of using MeshTraceRequest to perform a ray trace // Create a new MeshTraceRequest MeshTraceRequest traceRequest = new MeshTraceRequest(); // Configure the trace request with a ray traceRequest = traceRequest.Ray(new Vector3(0, 0, 0), new Vector3(1, 0, 0)); // Optionally, add tags to filter the trace traceRequest = traceRequest.WithTag("exampleTag"); // Run the trace MeshTraceRequest.Result result = traceRequest.Run(); // Check if the trace hit something if (result.Hit) { // Process the hit result Vector3 hitPosition = result.Position; // Additional processing... }