Vehicle Constraint: constraint_id

constraint_id
  • Returns the constraint ID.
  • Returns 0 if there isn't a constraint ID.

Return Type:
  • integer
Note:
  • The constraint ID is NOT the same thing as the constraint type.
  • The BGE assigns a new--and sometimes different--constraint ID number each time the constraint is created.
Sample Code

################  get the constraint ID

# import bge
import bge

# get current scene
scene = bge.logic.getCurrentScene()

# get object list
objList = scene.objects

# get object named RaceCar
obj1 = objList["RaceCar"]

# want to use a vehicle constraint
constraintType = 11

# get obj1 physics ID
obj1_ID = obj1.getPhysicsId()

# there isn't any obj 2
obj2_ID = 0

# create a vehicle constraint
car_Constraint = bge.constraints.createConstraint( obj1_ID, obj2_ID, constraintType )

# get the constraint ID
id_number = car_Constraint.constraint_id