SceneTrace HitTriggersOnly()

book_4_sparkGenerated
code_blocksInput

Description

The HitTriggersOnly method in the SceneTrace struct is used to configure a trace to only register hits with trigger objects. This method is part of the filtering options available in the SceneTrace class, allowing you to specify that the trace should only consider trigger objects as valid hits.

Usage

To use the HitTriggersOnly method, you typically chain it with other trace configuration methods on a SceneTrace instance. This method modifies the trace to ignore all non-trigger objects, ensuring that only trigger objects are considered during the trace operation.

Example

// Example of using HitTriggersOnly in a SceneTrace
SceneTrace trace = new SceneTrace();
trace = trace.HitTriggersOnly();

// Configure other trace parameters as needed
trace = trace.FromTo(startPosition, endPosition);

// Run the trace
SceneTraceResult result = trace.Run();

// Check if a trigger was hit
if (result.Hit)
{
    // Handle the hit
    GameObject hitObject = result.Entity;
    // Perform actions with the hit object
}