Vehicle Constraint: applyBraking

applyBraking(force, wheel)
  • Applies a braking force to a wheel.

force:
  • braking force
  • Type: float
wheel:
  • wheel to apply the braking force to.
  • Type: integer
  • 0 = first wheel added
  • 1 = second wheel added
  • 2 = third wheel added
  • 3 = fourth wheel added
Note:
  • applyBraking is persistent.
     
  • Once you apply the brakes, they stay applied.
     
  • To release the brakes, apply the brakes with a force of 0.0 (zero).
Sample Code

################ apply the brakes

#import bge
import bge

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

# get object list
objList = scene.objects

# get vehicle object named car
objCar = objList["Car"]
    
# Retrieve constraint ID you saved as a property when you created the vehicle constraint
constraint_ID = objCar["constraint_ID"]

# get the vehicle
vehicle = bge.constraints.getVehicleConstraint(constraint_ID)
 
# set braking force
force = 10.0

# brake with all four tires
vehicle.applyBraking( force, 0)
vehicle.applyBraking( force, 1)
vehicle.applyBraking( force, 2)
vehicle.applyBraking( force, 3)

Sample Code

################ release the brakes

#import bge
import bge

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

# get object list
objList = scene.objects

# get vehicle object named car
objCar = objList["Car"]
    
# Retrieve constraint ID you saved as a property when you created the vehicle constraint
constraint_ID = objCar["constraint_ID"]

# get the vehicle
vehicle = bge.constraints.getVehicleConstraint(constraint_ID)
 
# set the braking force to 0
force = 0.0

# release the brakes for all four tires
vehicle.applyBraking( force, 0)
vehicle.applyBraking( force, 1)
vehicle.applyBraking( force, 2)
vehicle.applyBraking( force, 3)