Description
The MassOverride
property allows you to specify a custom mass for the Rigidbody
component. This override is only applied if the value is greater than zero. It is useful when you need to set a specific mass for a physics body that differs from its default calculated mass.
Usage
To use the MassOverride
property, simply set it to a positive floating-point value to override the default mass of the Rigidbody
. If the value is set to zero or less, the override will not be applied, and the default mass will be used.
Example
// Example of setting the MassOverride property
Rigidbody myRigidbody = new Rigidbody();
myRigidbody.MassOverride = 10.0f; // Sets the mass to 10 units, overriding the default mass
// If you want to remove the override, set it to zero or a negative value
myRigidbody.MassOverride = 0.0f; // Removes the mass override, reverting to default mass