Enables (or disables) the motor of a joint that permit this behaviour.


GML Code Example

physics_joint_enable_motor(joint, motor)

Argument Description
joint The joint that you wish to enable or disable the motor on
motor Whether you wish to turn the motor on (true) or off (false)

Returns: N/A


When you have a joint with a motor (prismatic or revolute), you may want to be able to switch the motor on or off depending on variables and conditions within the game. For this, you need to have stored the index of the joint previously in a variable and then you can switch the motor on or off by using this function and setting the "motor" argument to true or false.


GML Code Example

var t_fix = physics_fixture_create();
 physics_fixture_set_circle_shape(t_fix, sprite_get_width(sprite_index) / 2);
 var o_id=instance_create(x+300, y, obj_Door);
 physics_fixture_bind(t_fix, id);
 physics_fixture_bind(t_fix, o_id);
 perma_joint = physics_joint_revolute_create(id, o_id, x+25, y, -90, 90, 1, 10, 2, 0, 0);
 physics_joint_enable(perma_joint, 1);

The above code creates and defines a new fixture and then creates an instance of "obj_Door", binding the created fixture to the two instances. They are then joined by a revolute joint with no motor and the angles limited to a +/- 90 degree swing, and we store the joint index in the variable "perma_joint". We then switch the motor on using this variable, before finally deleting the fixture from memory as it is no longer needed.

No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here