Description
The RunTraceAll
method in the PhysicsWorld
class is used to perform a physics trace operation that returns all the results of the trace. This method is useful when you need to gather information about all the objects that a trace intersects with, rather than just the first one.
Usage
To use the RunTraceAll
method, you need to have a PhysicsTraceBuilder
object that defines the parameters of the trace, such as the start and end points, the collision mask, and any other relevant settings. You pass this builder to the method by reference, and it returns an array of PhysicsTraceResult
objects, each representing an intersection found during the trace.
Example
// Create a PhysicsTraceBuilder to define the trace parameters
PhysicsTraceBuilder traceBuilder = new PhysicsTraceBuilder();
traceBuilder.Start = new Vector3(0, 0, 0);
traceBuilder.End = new Vector3(100, 0, 0);
traceBuilder.CollisionMask = CollisionLayer.Solid;
// Run the trace and get all results
PhysicsTraceResult[] results = physicsWorld.RunTraceAll(ref traceBuilder);
// Iterate through the results
foreach (var result in results)
{
// Process each result
var entity = result.Entity;
var position = result.Position;
// Additional processing...
}