Description
The Ray
method in the Editor.Trace
struct is a static method used to create a trace from one point in space to another. This method is particularly useful in the context of editor tools where you need to determine what is intersected by a ray in the 3D space of the editor.
Usage
To use the Ray
method, you need to provide two Vector3
references that represent the start and end points of the ray. The method returns an Editor.Trace
object that can be further configured or executed to perform the trace operation.
Example
// Example of using the Ray method
Vector3 startPoint = new Vector3(0, 0, 0);
Vector3 endPoint = new Vector3(10, 0, 0);
Editor.Trace trace = Editor.Trace.Ray(ref startPoint, ref endPoint);
// Further configuration of the trace can be done here
// For example, you might want to skip certain materials or only trace meshes
trace = trace.SkipToolsMaterials();
// Run the trace in a specific world context
Editor.MapDoc.MapWorld world = GetWorldContext();
Editor.TraceResult result = trace.Run(world);
// Check the result of the trace
if (result.Hit)
{
// Handle the hit result
var hitPosition = result.Position;
// Do something with the hit position
}