物理关节常量

GameMaker GML 中包含大量常量,这些常量特定于物理世界中固定装置之间的关节。这些函数可以与许多不同的关节函数配合使用,以便在运行物理模拟时实时设置或从中获取信息。但是,您应该注意,调用这些值时会执行复杂的计算,因此应该谨慎使用,并且只有在必要时才使用这些值,并且请注意,许多值对于特定类型的联接是唯一的。另请注意,虽然您可以使用适当的函数获取所有这些值,但是您只能设置那些标记为不是只读的值。

通常,这些常数将与以下函数一起使用:

 

以下常量可以应用于任何可用的关节:

物理关节常量
常量描述只读
phy_joint_anchor_1_xThe x coordinate of the first anchor point of the joint in the room
phy_joint_anchor_1_yThe y coordinate of the first anchor point of the joint in the room
phy_joint_anchor_2_xThe x coordinate of the second anchor point of the joint in the room
phy_joint_anchor_2_yThe y coordinate of the second anchor point of the joint in the room
phy_joint_reaction_force_xThis is the reaction force being applied to the second instance in a joint at the x anchor position
phy_joint_reaction_force_yThis is the reaction force being applied to the second instance in a joint at the y anchor position
phy_joint_reaction_torqueThis is the torque being applied to the second instance in a joint at the anchor position


这些常量适用于连接有马达的关节(旋转、棱柱、车轮):

物理关节常量
常量描述只读
phy_joint_max_motor_forceThe value specified when the joint was created for the maximum motor force
phy_joint_max_motor_torqueThe value specified when the joint was created for the maximum motor torque
phy_joint_motor_forceThe current motor force
phy_joint_motor_speedThe current motor speed
phy_joint_motor_torqueThe current motor torque


对于旋转关节,可以使用以下常量(如果添加了一个马达常量):

物理关节常量
常量描述只读
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.
phy_joint_angle_limitsEnable or disable angle limiting for the joint. Set the value to true to enable or false to disable.
phy_joint_upper_angle_limitThe upper angle limit for the joint in degrees.
phy_joint_lower_angle_limitThe lower angle limit for the joint in degrees.


对于棱柱关节,可以使用以下常量:

物理关节常量
常量描述只读
phy_joint_translationGets the distance between the anchor x/y coordinates and the local x/y coordinates.
phy_joint_speedThe current joint movement speed.


对于距离、焊接和车轮关节,可以使用以下常量(以及滑轮关节的常量):

物理关节常量
常量描述只读
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.
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().
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)
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)


对于滑动关节,可以使用以下常量:

物理关节常量
常量描述只读
phy_joint_max_torqueThe maximum torque value for the joint.
phy_joint_max_forceThe maximum force value for the joint.


对于绳索关节,可以使用以下常量:

物理关节常量
常量描述只读
phy_joint_max_lengthThe maximum extension for the connection between the two anchor points.