Description
The WithAnyTags
method is part of the MeshTraceRequest
struct within the Sandbox.Engine.Utility.RayTrace
namespace. This method allows you to specify a set of tags that the ray trace should consider. If any of the specified tags are present on the objects being traced, the trace will include those objects in its results.
Usage
Use the WithAnyTags
method when you want to perform a ray trace that should include objects with any of the specified tags. This is useful in scenarios where you are interested in multiple categories of objects and want to ensure that the trace does not miss any relevant objects.
To use this method, call it on an instance of MeshTraceRequest
and pass an array of strings representing the tags you are interested in. The method returns the modified MeshTraceRequest
instance, allowing for method chaining.
Example
// Example of using WithAnyTags method
// Create a new MeshTraceRequest
MeshTraceRequest traceRequest = new MeshTraceRequest();
// Define the tags you want to include in the trace
string[] tags = { "enemy", "obstacle", "collectible" };
// Configure the trace request to include any objects with the specified tags
traceRequest = traceRequest.WithAnyTags(tags);
// Run the trace
MeshTraceRequest.Result result = traceRequest.Run();
// Check if the trace hit any objects
if (result.Hit)
{
// Process the hit result
// For example, you can access the hit object or its position
}