Fixtures

Before an instance in GameMaker can have physical properties it must have a fixture assigned to it. A fixture binds a shape or form to the instance and this adds material properties such as density, friction, and restitution. Fixtures can be boxes, circles, polygons or any other simple shape you wish as GameMaker provides functions that enable you to define your own shape point by point, and then once you have your shape you can go ahead and define its physical properties too. These properties are what govern the way the instance with the fixture assigned to it will react with other instances in the physics world.

Properties

So as you can see, with just a few simple functions, GameMaker can help you to create complex systems and interactions which will give your games an unprecedented sense of realism.

NOTE You can define one fixture and have it bound to multiple instances (think of a pool table, where all the balls have the same physical properties, yet each one is a discreet entity). You can also bind multiple fixtures to a single instance and combine the physical properties (for example, using two triangular polygon fixtures to create a star)

Updating Existing Contacts

Two physics instances are "in contact" when their bounding boxes overlap (i.e. the rectangular regions surrounding their actual shapes). In this case, calling one of the physics_set_* functions on a bound fixture will change the value of the property, but in order to force the physics engine to also take this new value into account, you'll need to deactivate and reactivate the physics instance using phy_active

var _new_friction = 100;
phy_active = false;
physics_set_friction(fixture_id, _new_friction);
phy_active = true;

Function Reference

General

The following functions are for creating, binding, setting collisions and then deleting fixtures:

Shapes

A fixture must be given a shape or else it will not be detected by the physics world, and this shape can be defined by the following functions:

Setting Properties

In order for your physics enabled instance to react properly to the world around it, the fixtures you use must have specific properties defined that will give the fixture bounce, friction, mass, etc. The following functions are used to set these properties of the fixture:

Modifying Bound Fixtures

You can also set certain properties of the fixture after it has been bound to an instance. When binding the "base" fixture, you can choose to store the unique index for the bound physical properties in a variable. This can then be used in the following functions to change certain properties, or to get the current values for them: