physics_joint_delete

Delete a joint from the physics world.

Syntax:

physics_joint_delete(joint)


Argument Description
joint The index of the joint that you wish to delete


Returns: N/A


Description

Once two instances with physics representations have been bound by a joint, this can be deleted again at any time. Normally this will happen automatically when one of the two instances is destroyed, or when the room ends, but there are times when you may wish to do this manually. In those cases you would use this function.

It should also be noted that whenever an instance that is part of a gear joint is destroyed, the gear joint should be deleted using this function before any of the instances involved in forming the gear (but the remaining joints will be deleted automatically), for example in the destroy event of the instance.


Example:

var reactionForceX, reactionForceY, reactionForce;
if shipJoint
   {
   reactionForceX = physics_joint_get_value(shipJoint, phy_joint_reaction_force_x);
   reactionForceY = physics_joint_get_value(shipJoint, phy_joint_reaction_force_x);
   reactionForce = sqrt((reactionForceX + reactionForceX) + (reactionForceY + reactionForceY));
   if reactionForce > 2
      {
      physics_joint_delete(shipJoint);
      shipJoint = -1;
      }
   }

The above code checks to see if the variable "shipJoint" holds a joint index and if it does, it then calculates the force being applied to that joint using the two constants. Finally, if the total force is greater than 2, the joint is deleted.


Back: Joints
Next: physics_joint_enable_motor
© Copyright YoYo Games Ltd. 2019 All Rights Reserved