PhysicsTraceBuilder Sphere( float radius, Vector3& from, Vector3& to )
PhysicsTraceBuilder Sphere( float radius, Ray& ray, System.Single& distance )

robot_2Generated
code_blocksInput

Description

The Sphere method in the PhysicsTraceBuilder class is used to define a spherical trace in the physics simulation. This method allows you to specify a sphere with a given radius that traces from a starting point to an ending point in the 3D space. The trace will detect any collisions along the path of the sphere.

Usage

To use the Sphere method, you need to provide the following parameters:

  • radius: A float value representing the radius of the sphere.
  • from: A reference to a Vector3 indicating the starting position of the trace.
  • to: A reference to a Vector3 indicating the ending position of the trace.

The method returns a PhysicsTraceBuilder object, allowing for method chaining to further configure the trace or execute it.

Example

// Example of using the Sphere method in PhysicsTraceBuilder

// Define the start and end points of the trace
Vector3 startPoint = new Vector3(0, 0, 0);
Vector3 endPoint = new Vector3(10, 0, 0);

// Create a PhysicsTraceBuilder instance
PhysicsTraceBuilder traceBuilder = new PhysicsTraceBuilder();

// Configure the trace to use a sphere with a radius of 1.0f
traceBuilder.Sphere(1.0f, ref startPoint, ref endPoint);

// Run the trace and get the result
PhysicsTraceResult result = traceBuilder.Run();

// Check if the trace hit anything
if (result.Hit)
{
    // Handle the hit result
    // For example, you can access the hit position, normal, etc.
    Vector3 hitPosition = result.Position;
    // ...
}