Description
The Sphere
method in the SceneTrace
struct is used to perform a sphere trace from a starting point to an ending point in the scene. This method is useful for detecting collisions or intersections along a path defined by a sphere moving from one point to another.
Usage
To use the Sphere
method, you need to provide the radius of the sphere and the starting and ending points as Vector3
references. The method will return a SceneTrace
object that can be further configured or executed to perform the trace.
Example
// Example of using the Sphere method
Vector3 startPoint = new Vector3(0, 0, 0);
Vector3 endPoint = new Vector3(10, 0, 0);
float sphereRadius = 1.0f;
SceneTrace trace = new SceneTrace();
SceneTrace result = trace.Sphere(sphereRadius, ref startPoint, ref endPoint);
// Run the trace to get the result
SceneTraceResult traceResult = result.Run();
// Check if the trace hit anything
if (traceResult.Hit)
{
// Handle the hit
GameObject hitObject = traceResult.Entity;
// Do something with the hit object
}