Description
The Surface
field in the SceneTraceResult
struct represents the physical properties of the surface that was hit during a scene trace operation. This field is of type Sandbox.Surface
and provides detailed information about the material characteristics of the hit surface, such as friction, bounce, and other surface-specific properties.
Usage
To access the Surface
field, you need to perform a scene trace using the SceneTraceResult
struct. Once you have a trace result, you can read the Surface
field to understand the physical properties of the surface that was hit.
Note that this field is read-only and is automatically populated by the trace operation. It is not intended to be modified directly.
Example
// Example of using SceneTraceResult to access the Surface field
// Assume 'scene' is a valid Scene object and 'traceResult' is a SceneTraceResult
SceneTraceResult traceResult = SceneTraceResult.From(scene, out PhysicsTraceResult physicsResult);
if (traceResult.Hit)
{
// Access the Surface field
Sandbox.Surface hitSurface = traceResult.Surface;
// Use the surface properties
Console.WriteLine($"Hit surface friction: {hitSurface.Friction}");
Console.WriteLine($"Hit surface bounce: {hitSurface.Bounce}");
}