Surface Surface { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The Surface property of the PhysicsBody class represents the surface characteristics of the physics body. It is of type Sandbox.Surface, which encapsulates various properties related to the surface, such as friction and restitution, that affect how the physics body interacts with other objects in the simulation.

Usage

Use the Surface property to get or set the surface characteristics of a PhysicsBody. This can be useful for customizing how the body interacts with other objects, such as changing its friction or bounciness.

Example

// Example of setting the Surface property
PhysicsBody body = new PhysicsBody();
Sandbox.Surface customSurface = new Sandbox.Surface
{
    Friction = 0.5f,
    Restitution = 0.3f
};
body.Surface = customSurface;

// Accessing the Surface property
Sandbox.Surface currentSurface = body.Surface;
float friction = currentSurface.Friction;
float restitution = currentSurface.Restitution;