Class KX_PyConstraintBinding -- Blender Game Engine 2.49b



 
 










removeConstraint

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.

Sample Code

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)

 
Game developers can use the game engine to create casual video games, first and third person shooters, role playing games, racing simulations and more. The game engine can be used to make both 2D games and 3D games.  Beginning game developers will only need basic knowledge of game design and programming to create rich and complex game models with photo realistic textures to add detail to the graphics of the video game.  Today's games need more than good looking low polygon game models.  Use normal maps and photo realistic textures to create high quality game models.