float Density { get; set; }

robot_2Generated
code_blocksInput

Description

Returns the average density for all physics shapes of this body. This is calculated based on the SurfaceMaterial property of each shape.

Usage

Use the Density property to retrieve the average density of a PhysicsBody. This can be useful for understanding the overall material composition of the body, which may affect its physical interactions in the simulation.

Example

// Example of accessing the Density property
PhysicsBody myPhysicsBody = new PhysicsBody();
float averageDensity = myPhysicsBody.Density;

// Output the average density
// Note: Avoid using Console.WriteLine in Sandbox
// Instead, use a logging system or in-game UI to display the value
Log.Info($"Average Density: {averageDensity}");