Description
The WithTag
method is part of the MeshTraceRequest
struct within the Sandbox.Engine.Utility.RayTrace
namespace. This method allows you to specify a single tag that the mesh trace should consider when performing a ray trace operation. By using this method, you can filter the objects that the ray trace will interact with based on the specified tag.
Usage
To use the WithTag
method, you need to have an instance of MeshTraceRequest
. Call the method with a string parameter representing the tag you want to filter by. This method returns a new MeshTraceRequest
instance with the tag filter applied.
Example
// Example of using the WithTag method
MeshTraceRequest traceRequest = new MeshTraceRequest();
traceRequest = traceRequest.WithTag("enemy");
// Now, when you run the trace, it will only consider objects with the "enemy" tag
MeshTraceRequest.Result result = traceRequest.Run();
if (result.Hit)
{
// Handle the hit result
}