Description
The Mass
property of the Rigidbody
class represents the mass of the rigid body in the physics simulation. This property is crucial for determining how the rigid body interacts with forces and other objects in the simulation. The mass affects the inertia of the object, influencing how it accelerates under applied forces.
Note that this property is marked with the JsonIgnore
attribute, indicating that it is not serialized when the object is converted to JSON. This is typically done to prevent the mass from being directly manipulated through JSON data, ensuring that it is managed internally by the physics engine.
Usage
To use the Mass
property, you can access it directly from an instance of the Rigidbody
class. It is a read-only property, meaning you can retrieve the mass value but not set it directly. The mass is usually calculated based on the volume and density of the attached colliders, or it can be overridden using the MassOverride
property if a specific mass is desired.
Example usage:
Rigidbody rigidbody = new Rigidbody();
float currentMass = rigidbody.Mass;
Example
Rigidbody rigidbody = new Rigidbody();
float currentMass = rigidbody.Mass;
// Use currentMass in calculations or logic
if (currentMass > 10.0f)
{
// Perform actions based on mass
}