The Hit
field of the SceneTraceResult
struct indicates whether the trace operation successfully hit an object within the scene. It is a boolean value that returns true
if a hit was detected, and false
otherwise.
The Hit
field of the SceneTraceResult
struct indicates whether the trace operation successfully hit an object within the scene. It is a boolean value that returns true
if a hit was detected, and false
otherwise.
Use the Hit
field to determine if a trace operation has intersected with any objects in the scene. This can be useful for collision detection, raycasting, or any scenario where you need to know if a line or ray has intersected with an object.
// Example of using SceneTraceResult to check if a trace hit something Scene scene = ...; // Assume this is your current scene PhysicsTraceResult physicsResult = ...; // Assume this is your trace result SceneTraceResult traceResult = SceneTraceResult.From(ref scene, ref physicsResult); if (traceResult.Hit) { // The trace hit something GameObject hitObject = traceResult.GameObject; // Perform operations with the hit object } else { // The trace did not hit anything }