|
addWheeladdWheel(wheel, wheelPos, axlePos, wheelAxis,
suspensionHeight,
wheelRadius, steering)
Adds a wheel to the vehicle. wheel: Type:
KX_GameObject
(The game model of the tire.) wheelPos: Tire position from
vehicle object center.
Type: float list [ x, y, z] Uses local x, y, z float values. suspensionAngle: Cosine of the angle
(uses vehicle object center axis)
Type: float list [x, y, z] Range -1.0 to 1.0 wheelAxis: Axis of the tire
used to attach it to the axle.
Type: float list [ xAxis, yAxis, zAxis] Range -1.0 to 1.0 suspensionHeight: Height of the
suspension. Local value.
Type: float. wheelRadius: Radius of the tire.
Type: float steering:
Type: Bool
True or 1 = tire
used for steering.
False or 0 = tire not used for steering. Sample Code#import PhysicsConstraintsimport PhysicsConstraints# get list of objects in sceneobjList = GameLogic.getCurrentScene().objects# get vehicle object named carobjCar = objList["OBCar"]# keep the vehicle active, otherwise simulation stopsobjCar.applyImpulse([ 0.0, 0.0, 0.0], [ 0.0, 0.0, 0.0])# get car physics IDcar_PhysicsID = objCar.getPhysicsId()# create a vehicle constraintvehicle_Constraint = PhysicsConstraints.createConstraint(car_PhysicsID, 0, 11)# get the constraint IDconstraint_ID = vehicle_Constraint.getConstraintId()# save constraint_ID as a car variableobjCar.constraint_ID = constraint_ID# get the vehicle constraint IDvehicle = PhysicsConstraints.getVehicleConstraint(constraint_ID)# use the object names to get the tirestire_FD = objList["OBTire_1"]tire_FP = objList["OBTire_2"] tire_RD = objList["OBTire_3"] tire_RP = objList["OBTire_4"] # Front driver tire position from car object centertirePos_FD = [ -2.0, 4.0, -2.0]# Front passenger tire position from car object centertirePos_FP = [ 2.0, 4.0, -2.0]# Rear driver tire position from car object centertirePos_RD = [ -2.0, -4.0, -2.0]# Rear passenger tire position from car object centertirePos_RP = [ 2.0, -4.0, -2.0]# suspension angle from car object centersuspension_Angle = [ 0.0, 0.0, -1.0]# tire axis attached to car axletireAxis = [ -1.0, 0.0, 0.0]# set suspension heightsuspensionHeight_FD = 0.2suspensionHeight_FP = 0.2 suspensionHeight_RD = 0.2 suspensionHeight_RP = 0.2 # set tire radiustireRadius_FD = 1.0tireRadius_FP = 1.0 tireRadius_RD = 1.0 tireRadius_RP = 1.0 # tire has steering?tireSteer_FD = TruetireSteer_FP = True tireSteer_RD = False tireSteer_RP = False # Add front driver tire (tire 0)vehicle.addWheel( tire_FD, tirePos_FD, suspension_Angle, tireAxis,suspensionHeight_FD, tireRadius_FD, tireSteer_FD ) # Add front passenger tire (tire 1)vehicle.addWheel( tire_FP, tirePos_FP, suspension_Angle, tireAxis,suspensionHeight_FP, tireRadius_FP, tireSteer_FP ) # Add rear driver tire (tire 2)vehicle.addWheel( tire_RD, tirePos_RD, suspension_Angle, tireAxis,suspensionHeight_RD, tireRadius_RD, tireSteer_RD ) # Add rear passenger tire (tire 3)vehicle.addWheel( tire_RP, tirePos_RP, suspension_Angle, tireAxis,suspensionHeight_RP, tireRadius_RP, tireSteer_RP ) |