Collider:setMass
EditSets the mass of the Collider.
The relative mass of colliders determines how they react when they collide. A heavier collider has more momentum than a lighter collider moving the same speed, and will impart more force on the lighter collider.
More generally, heavier colliders react less to forces they receive, including forces applied with functions like Collider:applyForce
.
Colliders with higher mass do not fall faster. Use Collider:setLinearDamping
to give a collider drag to make it fall slower or Collider:setGravityScale
to change the way it reacts to gravity.
Collider:setMass(mass)
Arguments
Name | Type | Description |
mass | number | The new mass for the Collider, in kilograms. |
Returns
Nothing
Notes
The mass must be positive. Attempting to set a zero or negative mass will error.
By default, the mass of the Collider is kept up to date automatically as the Collider's shapes change. Use Collider:setAutomaticMass
to disable this.
Use Collider:resetMassData
to reset the mass based on the Collider's shapes.
If the Collider is kinematic or all translation axes are disabled, this function will do nothing.