
createConstraint(obj1_ID, obj2_ID, constraintType, pointPos_X, pointPos_Y, pointPos_Z)
- Creates a point to point physics constraint
- The physics ID of object 1.
- Object 1 is used as the line hinge anchor/pivot point.
- The physics ID of object 2.
Constraint Type:
- 0 = No Constraint
- 1 = bge.constraints.POINTTOPOINT_CONSTRAINT
- 2 = bge.constraints.LINEHINGE_CONSTRAINT
- 3 = bge.constraints.ANGULAR_CONSTRAINT
- 4 = bge.constraints.CONETWIST_CONSTRAINT
- 11 = bge.constraints.VEHICLE_CONSTRAINT
- 12 = bge.constraints.GENERIC_6DOF_CONSTRAINT (6 Degrees Of Freedom)
pointPos_X:
- The x position of the point to point constraint.
- X distance from the obj1 object center
- The y position of the point to point constraint.
- Y distance from the obj1 object center
- The z position of the point to point constraint.
- Z distance from the obj1 object center
Example Blends:

Sample Code

################ create a Point to Point Constraint
# import bge
import bge
# get current scene
scene = bge.logic.getCurrentScene()
# get object list
objList = scene.objects
# get object named Cube_Red
obj1 = objList["Cube_Red"]
# get object named Cube_Green
obj2 = objList["Cube_Green"]
# want to use a point to point constraint
constraintType = bge.constraints.POINTTOPOINT_CONSTRAINT
# get obj1 physics ID
obj1_ID = obj1.getPhysicsId()
# get obj2 physics ID
obj2_ID = obj2.getPhysicsId()
# Use front bottom right corner of obj1 for pivot point
pointPos_X = 1.0
pointPos_Y = -1.0
pointPos_Z = -1.0
# create a point to point constraint
cube_PtoP = bge.constraints.createConstraint( obj1_ID, obj2_ID, constraintType,
pointPos_X, pointPos_Y, pointPos_Z )