float Mass { get; set; }

robot_2Generated
code_blocksInput

Description

The Mass property of the Rigidbody class represents the mass of the rigidbody in the physics simulation. This property is read-only and is automatically calculated based on the attached colliders and their densities. It is used internally by the physics engine to determine how the rigidbody responds to forces and collisions.

Usage

Since the Mass property is read-only, you cannot directly set it. Instead, you can influence the mass by adjusting the properties of the colliders attached to the rigidbody, such as their density. If you need to override the calculated mass, you can use the MassOverride property, which allows you to specify a custom mass value when it is greater than zero.

Example

// Example of accessing the Mass property
Rigidbody rigidbody = new Rigidbody();
float mass = rigidbody.Mass;

// Output the mass of the rigidbody
// Note: This is a read-only property, so it cannot be set directly.
// To influence mass, adjust the properties of attached colliders.