physics_set_density

When you bind a fixture to an instance using physics_fixture_bind this returns an "id" for the bound fixture. You can use this id to set the density value of the bound fixture, not the "base" fixture, at any time using this function.

NOTE To make the physics engine use the new value in all cases, you'll need to deactivate and reactivate the physics instance using phy_active. See Updating Existing Contacts.

 

Syntax:

physics_set_density(fixture, density)

ArgumentTypeDescription
fixturePhysics Fixture IDthe id of the bound fixture
densityRealthe new density value to apply

 

Returns:

N/A

 

Example:

var density = physics_get_density(fix_id);
physics_set_density(fix_id, density - 0.1);

The code above gets the current density value for the bound physics properties of the instance and then sets them to a different value.