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 on this instance and pass the desired tag as a string parameter. This will configure the trace request to only consider objects with the specified tag.
Example
// Create a new MeshTraceRequest
MeshTraceRequest traceRequest = new MeshTraceRequest();
// Specify the tag to filter the trace
traceRequest = traceRequest.WithTag("enemy");
// Run the trace
MeshTraceRequest.Result result = traceRequest.Run();
// Check if the trace hit an object
if (result.Hit)
{
// Handle the hit result
// For example, get the entity that was hit
Entity hitEntity = result.Entity;
}