book_4_sparkGenerated
code_blocksInput

Description

The From method is a static method of the SceneTraceResult struct in the Sandbox namespace. It is used to create a SceneTraceResult from a given Scene and a PhysicsTraceResult. This method is particularly useful for converting the results of a physics trace into a scene trace result, which can then be used to determine various properties of the trace, such as whether it hit an object, the distance of the trace, and the object that was hit.

Usage

To use the From method, you need to have a reference to a Scene and a PhysicsTraceResult. You can then call the method statically on the SceneTraceResult struct to obtain a new SceneTraceResult instance.

Example usage:

Scene scene = ...; // Obtain a reference to the scene
PhysicsTraceResult physicsResult = ...; // Perform a physics trace and get the result
SceneTraceResult sceneTraceResult = SceneTraceResult.From(ref scene, ref physicsResult);

After obtaining the SceneTraceResult, you can access its properties to get information about the trace, such as Hit, Distance, GameObject, and more.

Example

Scene scene = ...; // Obtain a reference to the scene
PhysicsTraceResult physicsResult = ...; // Perform a physics trace and get the result
SceneTraceResult sceneTraceResult = SceneTraceResult.From(ref scene, ref physicsResult);

if (sceneTraceResult.Hit)
{
    Console.WriteLine($"Hit object: {sceneTraceResult.GameObject}");
    Console.WriteLine($"Hit position: {sceneTraceResult.HitPosition}");
}