The Component
field in the SceneTraceResult
struct represents the specific Component
that was hit during a scene trace operation. This field is read-only and provides information about the component that was intersected by the trace.
The Component
field in the SceneTraceResult
struct represents the specific Component
that was hit during a scene trace operation. This field is read-only and provides information about the component that was intersected by the trace.
Use the Component
field to determine which component of a GameObject
was hit during a trace. This can be useful for identifying specific parts of a complex object that were interacted with, allowing for more detailed collision handling or interaction logic.
// Example of using SceneTraceResult to get the hit component SceneTraceResult traceResult = SceneTraceResult.From(scene, ref physicsTraceResult); if (traceResult.Hit) { Component hitComponent = traceResult.Component; // Perform operations with the hit component // For example, logging the component's name string componentName = hitComponent?.Name ?? "Unknown Component"; // Use componentName as needed }