Vehicle Constraint: createConstraint

createConstraint(obj1_ID, obj2_ID, constraintType)
  • Creates a vehicle constraint

obj1_ID:
  • The physics ID of object 1.
  • Object 1 is the vehicle.
     
  • Type: integer
obj2_ID:
  • 0 (zero)
  • Type: integer
     
  • There isn't an 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)
Example Blends:
Sample Code


################  create a vehicle Constraint

# import bge
import bge

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

# get object list
objList = scene.objects

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

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

# there isn't any obj 2
obj2_ID = 0

# want to use a vehicle constraint
constraintType = bge.constraints.VEHICLE_CONSTRAINT

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