removeConstraint(constraint_ID)
Removes the constraint.
constraint_ID
Type:
integer
Note:
Save the constraintID when the constraint is created.
Note:
This removes the constraint between 2 game objects
(point and edge constraints). It does not remove vehicle
constraints.
Part
1: Create a Point Constraint
######### PointConstraint.py
# import PhysicConstraints Module
import PhysicsConstraints
# get object list
objList = GameLogic.getCurrentScene().objects
# get object named Obj_1
obj1 = objList["OBObj_1"]
# get object named Obj_2
obj2 = objList["OBObj_2"]
# use point constraint type
constraintType = 1
# get Obj_1 physics ID
obj1_ID = obj1.getPhysicsId()
# get Obj_2 physics ID
obj2_ID = obj2.getPhysicsId()
# Use bottom right front corner of obj1 for point
position
pointPos_x = 1.0
pointPos_y = -1.0
pointPos_z = -1.0
# create a point constraint
constraint = PhysicsConstraints.createConstraint( obj1_ID, obj2_ID,
constraintType,
pointPos_x, pointPos_y,
pointPos_z)
# get the constraint ID
constraint_ID = constraint.getConstraintId()
# save the constraint ID as an Obj_1 variable
obj1["constraint_ID"] = constraint_ID
Part
2: Remove constraint script
########### RemoveConstraint.py
# import PhysicConstraints Module
import PhysicsConstraints
# get object list
objList = GameLogic.getCurrentScene().objects
# get object 1
obj1 = objList["OBObj_1"]
# get constraint ID that was saved as an Obj_1 variable
# when the constraint was created
constraint_ID = obj1["constraint_ID"]
# remove constraint
PhysicsConstraints.removeConstraint(constraint_ID)