Physics Joint Constants

There are a great number of constants included within the GameMaker GML that are specific to joints between fixtures in the physics world. These can be used in conjunction with many of the different joint functions to set or get information from them in real time while the physics simulation is running. You should be aware, however, that complex calculations are done when you call these, so they should be used with care and only when necessary and note that many are unique to a specific type of joint. Also note that while you can get all these values with the appropriate function, you can only set those that are marked as not being read-only.

In general these constants would be used in conjunction with the following functions:

 

The following constants can be applied to any of the available joint types:

Physics Joint Constant
ConstantDescriptionRead Only
phy_joint_anchor_1_xThe x coordinate of the first anchor point of the joint in the roomYes
phy_joint_anchor_1_yThe y coordinate of the first anchor point of the joint in the roomYes
phy_joint_anchor_2_xThe x coordinate of the second anchor point of the joint in the roomYes
phy_joint_anchor_2_yThe y coordinate of the second anchor point of the joint in the roomYes
phy_joint_reaction_force_xThis is the reaction force being applied to the second instance in a joint at the x anchor positionYes
phy_joint_reaction_force_yThis is the reaction force being applied to the second instance in a joint at the y anchor positionYes
phy_joint_reaction_torqueThis is the torque being applied to the second instance in a joint at the anchor positionYes


These constants are for those joints that have a motor attached to them (revolute, prismatic, wheel):

Physics Joint Constant
ConstantDescriptionRead Only
phy_joint_max_motor_forceThe value specified when the joint was created for the maximum motor forceNo
phy_joint_max_motor_torqueThe value specified when the joint was created for the maximum motor torqueNo
phy_joint_motor_forceThe current motor forceYes
phy_joint_motor_speedThe current motor speedNo
phy_joint_motor_torqueThe current motor torqueYes


For a revolute joint you can use the following constant (as well as the motor constants if one has been added):

Physics Joint Constant
ConstantDescriptionRead Only
phy_joint_angleThe angle that a line between the two anchor points of the joint makes. This is calculated using the physics world coordinates
(not the GameMaker room coordinates) in radians.
Yes
phy_joint_angle_limitsEnable or disable angle limiting for the joint. Set the value to true to enable or false to disable.No
phy_joint_upper_angle_limitThe upper angle limit for the joint in degrees.No
phy_joint_lower_angle_limitThe lower angle limit for the joint in degrees.No


For a prismatic joint you can use the following constant:

Physics Joint Constant
ConstantDescriptionRead Only
phy_joint_translationGets the distance between the anchor x/y coordinates and the local x/y coordinates.Yes
phy_joint_speedThe current joint movement speed.Yes


For a distance, weld, and wheel joints you can use the following constants (as well as those for pulley joints):

Physics Joint Constant
ConstantDescriptionRead Only
phy_joint_damping_ratioThe damping ratio is non-dimensional and defines the "springiness" of the joint. The value for this constant is typically between 0 and 1, but can be larger, and at 1, the damping is critical meaning that all oscillations should vanish.No
phy_joint_frequencyThis will return (or set) the oscillation frequency for the joint, in hertz, and typically the frequency should be less than a half the frequency of the time step, as set by the function physics_world_update_speed().No
phy_joint_length_1This will return the length of the joint from the first local x/y coordinates to the first anchor x/y coordinates (Distance joints only, can only be read from)Yes
phy_joint_length_2This will return the length of the joint from the second local x/y coordinates to the second anchor x/y coordinates (Distance joints only, can only be written to)No


For a friction joint you can use the following constants:

Physics Joint Constant
ConstantDescriptionRead Only
phy_joint_max_torqueThe maximum torque value for the joint.No
phy_joint_max_forceThe maximum force value for the joint.No


For a rope joint you can use the following constant:

Physics Joint Constant
ConstantDescriptionRead Only
phy_joint_max_lengthThe maximum extension for the connection between the two anchor points.No