float Mass { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The Mass property of the PhysicsBody class represents the mass of the physics body. This property is crucial for determining how the body interacts with forces and other objects in the physics simulation. The mass affects the body's inertia and how it responds to applied forces, such as gravity or impulses.

Usage

To get or set the mass of a PhysicsBody, use the Mass property. Setting the mass directly can be useful when you want to define a specific mass for the body, rather than relying on the automatic calculation based on the body's volume and density.

Example

// Example of setting the mass of a PhysicsBody
PhysicsBody body = new PhysicsBody();
body.Mass = 10.0f; // Set the mass to 10 units

// Example of getting the mass of a PhysicsBody
float currentMass = body.Mass;
Console.WriteLine($"The mass of the body is: {currentMass}");