Vehicle Constraint: getVehicleConstraint

getVehicleConstraint(constraint_id)
  • Returns the vehicle ID number
     
  • Return Type: integer

constraint_id:
  • The id number of the vehicle constraint.
     
  • Type: integer
Note:
  • The constraint ID is NOT the same thing as the constraint type.
Sample Code

 

################  get the vehicle ID number

# 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
constraint_id = car_Constraint.getConstraintId()

# get the vehicle ID number
car = bge.constraints.getVehicleConstraint(constraint_id)