## 物理关节常量

There are a great number of constants included within the GameMaker Studio 2 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.

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

phy_joint_anchor_1_x The x coordinate of the first anchor point of the joint in the room
phy_joint_anchor_1_y The y coordinate of the first anchor point of the joint in the room
phy_joint_anchor_2_x The x coordinate of the second anchor point of the joint in the room
phy_joint_anchor_2_y The y coordinate of the second anchor point of the joint in the room
phy_joint_reaction_force_x This is the reaction force being applied to the second instance in a joint at the x anchor position
phy_joint_reaction_force_y This is the reaction force being applied to the second instance in a joint at the y anchor position
phy_joint_reaction_torque This is the torque being applied to the second instance in a joint at the anchor position

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

phy_joint_max_motor_force The value specified when the joint was created for the maximum motor force
phy_joint_max_motor_torque The value specified when the joint was created for the maximum motor torque
phy_joint_motor_force The current motor force
phy_joint_motor_speed The current motor speed
phy_joint_motor_torque The current motor torque

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

phy_joint_angle The angle that a line between the two anchor points of the joint makes. This is calculated using the physics world coordinates
(not the GameMaker Studio 2 room coordinates) in radians.
phy_joint_angle_limits Enable or disable angle limiting for the joint. Set the value to true to enable or false to disable.
phy_joint_upper_angle_limit The upper angle limit for the joint in degrees.
phy_joint_lower_angle_limit The lower angle limit for the joint in degrees.

For a prismatic joint you can use the following constant:

phy_joint_translation Gets the distance between the anchor x/y coordinates and the local x/y coordinates.
phy_joint_speed The current joint movement speed.

For a pulley joint you can use the following constants (as well as those for distance joints):

phy_joint_length_1 This will return the length of the joint from the first local x/y coordinates to the first anchor x/y coordinates
phy_joint_length_2 This will return the length of the joint from the second local x/y coordinates to the second anchor x/y coordinates

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

phy_joint_damping_ratio The 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.
phy_joint_frequency This 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.

For a friction joint you can use the following constants:

phy_joint_max_torque The maximum torque value for the joint.
phy_joint_max_force The maximum force value for the joint.

For a rope joint you can use the following constant:

phy_joint_max_length The maximum extension for the connection between the two anchor points.