The Run
method of the SceneTrace
struct executes the trace operation and returns the result of the first hit encountered. This method is useful for determining the first object that a trace intersects with in the scene.
The Run
method of the SceneTrace
struct executes the trace operation and returns the result of the first hit encountered. This method is useful for determining the first object that a trace intersects with in the scene.
To use the Run
method, first configure a SceneTrace
object with the desired parameters, such as the start and end points, shape, and any filters. Once configured, call the Run
method to perform the trace and obtain the result.
// Example of using SceneTrace to perform a trace and get the first hit SceneTrace trace = new SceneTrace(); trace.FromTo(startPosition, endPosition); trace.Radius(0.5f); // Set the trace to be a sphere with a radius of 0.5 SceneTraceResult result = trace.Run(); if (result.Hit) { // Process the hit result GameObject hitObject = result.Entity; Vector3 hitPosition = result.Position; // Additional logic here }