Collider:getMass

Edit

Returns 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.

mass = Collider:getMass()

Arguments

None

Returns

NameTypeDescription
massnumber The mass of the Collider, in kilograms.

Notes

By default, the mass of the Collider will be kept up to date automatically as shapes are added and removed from the Collider (or if the shapes change size or density). Use Collider:setAutomaticMass to customize this.

Mass can be overridden with Collider:setMass, or recomputed from the attached shapes with Collider:resetMassData.

If the Collider is kinematic or all translation axes are disabled, this returns 0.

See also