GameMaker GML 中包含大量常量,这些常量特定于物理世界中固定装置之间的关节。这些函数可以与许多不同的关节函数配合使用,以便在运行物理模拟时实时设置或从中获取信息。但是,您应该注意,调用这些值时会执行复杂的计算,因此应该谨慎使用,并且只有在必要时才使用这些值,并且请注意,许多值对于特定类型的联接是唯一的。另请注意,虽然您可以使用适当的函数获取所有这些值,但是您只能设置那些标记为不是只读的值。
通常,这些常数将与以下函数一起使用:
以下常量可以应用于任何可用的关节:
物理关节常量 | ||
---|---|---|
常量 | 描述 | 只读 |
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 | 是 |
这些常量适用于连接有马达的关节(旋转、棱柱、车轮):
物理关节常量 | ||
---|---|---|
常量 | 描述 | 只读 |
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 | 是 |
对于旋转关节,可以使用以下常量(如果添加了一个马达常量):
物理关节常量 | ||
---|---|---|
常量 | 描述 | 只读 |
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 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. | 否 |
对于棱柱关节,可以使用以下常量:
物理关节常量 | ||
---|---|---|
常量 | 描述 | 只读 |
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. | 是 |
对于距离、焊接和车轮关节,可以使用以下常量(以及滑轮关节的常量):
物理关节常量 | ||
---|---|---|
常量 | 描述 | 只读 |
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(). | 否 |
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 (Distance joints only, can only be read from) | 是 |
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 (Distance joints only, can only be written to) | 否 |
对于滑动关节,可以使用以下常量:
物理关节常量 | ||
---|---|---|
常量 | 描述 | 只读 |
phy_joint_max_torque | The maximum torque value for the joint. | 否 |
phy_joint_max_force | The maximum force value for the joint. | 否 |
对于绳索关节,可以使用以下常量:
物理关节常量 | ||
---|---|---|
常量 | 描述 | 只读 |
phy_joint_max_length | The maximum extension for the connection between the two anchor points. | 否 |