2D Constraints (Joints)

Function CreateDistanceJoint(spriteA, spriteB, aX, aY, bX, bY, collide_connect)

Creates a distance joint

A distance joint constrains two points on two bodies to remain at a fixed distance from each other. You can view this as a massless, rigid rod.

Parameters

  • spriteA - first body.
  • spriteB - second body.
  • aX, aY - Anchor point on spriteA.
  • bX, bY - Anchor point on spriteB.

Function CreateFrictionJoint(spriteA, spriteB, x, y, collide_connect)

Creates a Friction

Friction joint. This is used for top-down friction. It provides 2D translational friction and angular friction.

Paramentes:

  • spriteA - first body.
  • spriteB - second body
  • x, y - Anchor point. A common world-space point where the firction forces will be applied on both bodies. This is usually set to the point where you want rhe bodies to "grip" or resist slipping relative to each otrher.

Function CreateGearJoint(jointA, jointB, g_ratio, collide_connect)

Creates a Gear Joint A gear joint is used to connect two joints together. Either joint can be a revolute or prismatic joint. You specify a gear ratio to bind the motions together: coordinate1 + ratio * coordinate2 = constant The ratio can be negative or positive. If one joint is a revolute joint and the other joint is a prismatic joint, then the ratio will have units of length or units of 1/length.

Parameters:

  • spriteA - first body.
  • spriteB - second body.
  • ratio - ratio of how much influence jointA has compared to jointB.

Function CreateMotorJoint(spriteA, spriteB, collide_connect)

Creates a Motor Joint A motor joint is used to control the relative motion between two bodies. A typical usage is to control the movement of a dynamic body with respect to the ground.


Function CreatePrismaticJoint(spriteA, spriteB, aX, aY, axisX, axisY, collide_connect)

Creates a Prismatic Joint

A prismatic joint. This joint provides one degree of freedom: translation along an axis fixed in bodyA. Relative rotation is prevented. You can use a joint limit to restrict the range of motion and a joint motor to drive the motion or to model joint friction.

Parameters:

  • spriteA - first body
  • spriteB - second body
  • aX, aY - anchor point
  • axisX, axisY - Used to define a linear direction from anchor point.

Function CreatePulleyJoint(spriteA, spriteB, gaX, gaY, gbX, gbY, aX, aY, bX, bY, j_ratio, collide_connect)

Creates a pulley joint

The pulley joint is connected to two bodies and two fixed ground points. The pulley supports a ratio such that: length1 + ratio * length2


Function CreateRevoluteJoint(spriteA, spriteB, x, y, collide_connect)

Creates a revolute joint A revolute joint

constrains two bodies to share a common point while they are free to rotate about the point. The relative rotation about the shared point is the joint angle. You can limit the relative rotation with a joint limit that specifies a lower and upper angle. You can use a motor to drive the relative rotation about the shared point. A maximum motor torque is prov


Function CreateWeldJoint(spriteA, spriteB, x, y, collide_connect)

Creates a Weld Joint A weld joint

essentially glues two bodies together. A weld joint may distort somewhat because the island constraint solver is approximate.


Function CreateWheelJoint(spriteA, spriteB, aX, aY, axisX, axisY, collide_connect)

Creates a wheel joint. A wheel joint. This joint provides two degrees of freedom: translation along an axis fixed in bodyA and rotation in the plane. In other words, it is a point to line constraint with a rotational motor and a linear spring/damper. The spring/damper is initialized upon creation. This joint is designed for vehicle suspensions.


Sub GetJointWorldAnchorA(joint_id, ByRef x, ByRef y)

Get the anchor point on bodyA in world coordinates. Can be used with all joints

See also

GetJointWorldAnchorB()


Function GetJointWorldAnchorB(joint_id, ByRef x, ByRef y)

Get the anchor point on bodyB in world coordinates. Can be used with all joints

See also

GetJointWorldAnchorA()


Sub GetJointReactionForce(joint_id, inv_dt, ByRef x, ByRef y)

Returns the reaction force on bodyB at the joint anchor in Newtons. Can be used with all joints

See also

GetJointReactionTorque()


Function GetJointReactionTorque(joint_id, inv_dt)

Returns the reaction torque on bodyB in N*m Can be used with all joints

See also

GetJointReactionForce()


Sub GetJointLocalAnchorA(joint_id, ByRef x, ByRef y)

Returns the local anchor point relative to bodyA’s origin.

  • Distance Joint
  • Friction Joint
  • Prismatic Joint
  • Revolute Joint
  • Weld Joint
  • Wheel Joint

See also

GetJointLocalAnchorB()


Sub GetJointLocalAnchorB(joint_id, ByRef x, ByRef y)

Returns the local anchor point relative to bodyB’s origin.

  • Distance Joint
  • Friction Joint
  • Prismatic Joint
  • Revolute Joint
  • Weld Joint
  • Wheel Joint

See also

GetJointLocalAnchorA()


Function SetJointLength(joint_id, jlen)

Set the fixed distance between two connected bodies. This distance acts as a “target length” that the joint will try to maintain, applying forces to keep the bodies at that separation. Used with distance Joints

See also

GetJointLength()


Function GetJointLength(joint_id)

Returns the Joint Length Used with distance Joints

See also

SetJointLength()


Sub SetJointMinLength(joint_id, jlen)

Set the minimum allowable length between two connected bodies Used with Distance Joint

See also

SetJointMaxLength()


Function GetJointMinLength(joint_id)

Returns the minimum length Used with Distance Joint

See also

GetJointMaxLength()


Sub SetJointMaxLength(joint_id, jlen)

Set the maximum allowable length between two connected bodies Used with Distance Joint

See also

SetJointMinLength()


Function GetJointMaxLength(joint_id)

Returns the maximum length Used with Distance Joint

See also

GetJointMinLength()


Function GetJointCurrentLength(joint_id)

Returns the current distance between BodyA and BodyB

Used with:

  • Distance Joint

See also

GetJointLength()


Sub SetJointStiffness(joint_id, stiffness)

Sets how rigid a joint is.

Used with:

  • Distance Joint
  • Weld Joint
  • Wheel Join

See also

GetJointStiffness()


Function GetJointStiffness(joint_id)

Returns spring stiffness

Used with:

  • Distance Joint
  • Weld Joint
  • Wheel Joint

See also

SetJointStiffness()


Sub SetJointDamping(joint_id, damping)

Sets the damping value for a joint

Used with:

  • Distance Joint
  • Weld Joint
  • Wheel Joint

See also

GetJointDamping()


Function GetJointDamping(joint_id)

Returns the damping value for a joint

Used with:

  • Distance Joint
  • Weld Joint
  • Wheel Joint

See also

SetJointDamping()


Sub SetJointMaxForce(joint_id, force)

Sets an upper limit on the amount of force the joint can apply to the connected bodies, helping to control how much resistance or power the joint provides.

Used with:

  • Motor Joint
  • Friction Joint

Function GetJointMaxForce(joint_id)

Return the maximum friction force in N.

Used with:

  • Friction Joint
  • Motor Joint

Sub SetJointMaxTorque(joint_id, torque)

Sets an upper limit on the amount of torque (rotational force) the joint can apply, controlling how much rotational resistance or power the joint provides.

Used with:

  • Friction Joint
  • Motor Joint

See also

GetJointMaxTorque()


Function GetJointMaxTorque(joint_id)

Returns the upper limit on the amount of torque (rotational force) the joint can apply, controlling how much rotational resistance or power the joint provides.

Used with:

  • Friction Joint
  • Motor Joint

See also

SetJointMaxTorque()


Sub SetJointCorrectionFactor(joint_id, factor)

Sets how quickly the joint corrects deviations from its target position and rotation. This correction factor determines the responsiveness of the motor joint in achieving the desired linear and angular offsets between two connected bodies.

Used with Motor Joints

See also

GetJointCorrectionFactor()


Function GetJointCorrectionFactor(joint_id)

Returns a factor for how quickly the joint corrects deviations from its target position and rotation. This correction factor determines the responsiveness of the motor joint in achieving the desired linear and angular offsets between two connected bodies.

Used with Motor Joints

See also

GetJointCorrectionFactor()


Sub SetJointRatio(joint_id, j_ratio)

Determines how much one joint’s movement affects the other, enabling complex, synchronized motion.

Used with Gear Joints

See also

GetJointRatio()


Function GetJointRatio(joint_id)

Returns the gear/pulley ratio

Used with:

  • Gear Joint
  • Pulley Joint

See also

SetJointRatio()


Sub SetJointLinearOffset(joint_id, x, y)

Specify a target position offset for the connected bodies relative to each other.

Used with Motor Joints

See also

GetJointLinearOffset()


Sub GetJointLinearOffset(joint_id, ByRef x, ByRef y)

Gets the target position offset for the connected bodies relative to each other.

Used with Motor Joints

See also

SetJointLinearOffset()


Sub SetJointAngularOffset(joint_id, angleOffset)

Set the target angular offset

Used with Motor Joint

See also

GetJointAngularOffset()


Function GetJointAngularOffset(joint_id)

Returns the target angular offset

Used with Motor Joint

See also

SetJointAngularOffset()


Sub GetJointLocalAxisA(joint_id, ByRef x, ByRef y)

Gets the local joint axis relative to bodyA Used with Prismatic Joint Wheel Joint

Used with:

  • Prismatic Joint
  • Revolute Joint

Function GetJointReferenceAngle(joint_id)

Returns the reference angle. Used with Prismatic Joint Revolute Joint

Used with:

  • Prismatic Joint
  • Revolute Joint

Function GetJointTranslation(joint_id)

Returns the current joint translation, usually in meters. Used with Prismatic Joint Wheel Joint

Used with:

  • Prismatic Joint
  • Revolute Joint

Function GetJointSpeed(joint_id)

Returns the current joint angle speed Used with Prismatic Joint Revolute Joint

Used with:

  • Prismatic Joint
  • Revolute Joint

Function JointIsLimitEnabled(joint_id)

Returns whether or not the joint limit is enabled Used with Prismatic Joint Revolute Joint Wheel Joint

Used with:

  • Prismatic Joint
  • Revolute Joint
  • Wheel Joint

See also

EnableJointLimit(), SetJointLimits()


Sub EnableJointLimit(joint_id, flag)

Enables or disables joint limits Used with Prismatic Joint Revolute Joint Wheel Joint

Used with:

  • Prismatic Joint
  • Revolute Joint
  • Wheel Joint

See also

JointIsLimitEnabled(), SetJointLimits()


Function GetJointLowerLimit(joint_id)

Get the lower joint translation limit, usually in meters. Used with Prismatic Joint Revolute Joint Wheel Joint

Used with:

  • Prismatic Joint
  • Revolute Joint
  • Wheel Joint

See also

GetJointUpperLimit()


Function GetJointUpperLimit(joint_id)

Get the upper joint translation limit, usually in meters. Used with Prismatic Joint Revolute Joint Wheel Joint

Used with:

  • Prismatic Joint
  • Revolute Joint
  • Wheel Joint

See also

GetJointLowerLimit()


Sub SetJointLimits(joint_id, lower_limit, upper_limit)

Sets the minimum and maximum limits, restricting how far or how much rotation the connected bodies can move relative to each other. Used with Prismatic Joint Revolute Joint Wheel Joint

Used with:

  • Prismatic Joint
  • Revolute Joint
  • Wheel Joint

See also

GetJointLowerLimit(), GetJointUpperLimit()


Function JointMotorIsEnabled(joint_id)

Returns whether or not the joint motor is enabled Used with Prismatic Joint Revolute Joint Wheel Joint

Used with:

  • Prismatic Joint
  • Revolute Joint
  • Wheel Joint

See also

EnableJointMotor()


Sub EnableJointMotor(joint_id, flag)

Enables or disables the joint motor Used with Prismatic Joint Revolute Joint Wheel Joint

Used with:

  • Prismatic Joint
  • Revolute Joint
  • Wheel Joint

See also

JointMotorIsEnabled()


Sub SetJointMotorSpeed(joint_id, speed)

Used on joints that support motors, such as revolute joints and prismatic joints, to control the speed at which the motor applies force to achieve movement. Used with Prismatic Joint Revolute Joint Wheel Joint

Used with:

  • Prismatic Joint
  • Revolute Joint
  • Wheel Joint

See also

GetJointMotorSpeed()


Function GetJointMotorSpeed(joint_id)

Returns the motor speed Used with Prismatic Joint Revolute Joint Wheel Joint

Used with:

  • Prismatic Joint
  • Revolute Joint
  • Wheel Joint

See also

SetJointMotorSpeed()


Sub SetJointMaxMotorForce(joint_id, force)

Limits the maximum linear force that the motor can apply to achieve the target speed set by SetMotorSpeed. This allows you to control the power or strength of the motor along the joint’s axis. Used with Prismatic Joints

See also

GetJointMaxMotorForce()


Function GetJointMaxMotorForce(joint_id)

Returns the maximum linear force that the motor can apply to achieve the target speed set by SetMotorSpeed. This allows you to control the power or strength of the motor along the joint’s axis. Used with Prismatic Joint

See also

SetJointMaxMotorForce()


Function GetJointMotorTorque(joint_id, inv_dt)

Returns the current motor torque given the inverse time step. Unit is N*m. Used with Revolute Joint Wheel Joint

See also

GetJointMaxMotorTorque(), SetJointMaxMotorTorque()


Sub GetJointGroundAnchorA(joint_id, ByRef x, ByRef y)

Gets the first ground anchor

Used with Pulley Joint

See also

GetJointGroundAnchorB


Sub GetJointGroundAnchorB(joint_id, inv_dt)

Gets the second ground anchor

Used with Pulley Joint

See also

GetJointGroundAnchorA()


Function GetJointLengthA(joint_id)

Returns the current length of the line connecting the anchor point on the first body to its corresponding ground anchor. This length can vary based on the movement of the connected bodies.

Used with Pulley Joints

See also

GetJointLengthB()


Function GetJointLengthB(joint_id)

Returns the current length of the line connecting the anchor point on the second body to its corresponding ground anchor. This length can vary based on the movement of the connected bodies.

Used with Pulley Joints

See also

GetJointLengthA()


Function GetJointCurrentLengthA(joint_id)

Return the current length of the segment attached to bodyA.

Used with Pulley Joint

See also

GetJointCurrentLengthB()


Function GetJointCurrentLengthB(joint_id)

Return the current length of the segment attached to bodyB.

Used with Pulley Joint

See also

GetJointCurrentLengthA()


Sub SetJointOrigin(joint_id, x, y)

Shift the world origin. This is particularly useful in large simulations where objects might move far from the initial origin, potentially causing precision issues in floating-point calculations.

Used with Pulley Joint


Function GetJointAngle(joint_id)

Returns the current joint angle

Used with:

  • Revolute Joint
  • Wheel Joint

  • Function GetJointLinearSpeed(joint_id)

    Returns the current joint linear speed, usually in meters per second.

    Used with Wheel Joint


    Function GetJointAngularSpeed(joint_id)

    Return the current joint angular speed

    Used with Wheel Joint


    Sub DeleteJoint(joint_id)

    Clears a joint from memory.

    See also

    CreateDistanceJoint(), CreateFrictionJoint(), CreateGearJoint(), CreateMotorJoint(), CreatePrismaticJoint(), CreatePulleyJoint(), CreateRevoluteJoint(), CreateWeldJoint(), CreateWheelJoint()


    Function JointExists(joint_id)

    returns true if it exists or false if it does not exist.