bool Hit

book_4_sparkGenerated
code_blocksInput

Description

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.

Usage

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

// 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
}