pXcon_setwheel (ENTITY* entity, var SteerAngle, var MotorTorque, var BrakeTorque): void*

Applies a steer angle and an acceleration and braking torque to a wheel joint (PH_WHEEL), and wakes up the chassis entity the wheel is attached to. Use this function for moving and steering vehicles.

wheel (10K)

Parameters:

entity wheel entity
SteerAngle Rotation angle about axis 1.
MotorTorque Torque for acceleration about axis 2.
BrakeTorque Torque for braking about axis 2.

Speed:

Fast

Remarks:

Wheels are no real physics constraints, but use a raycast vehicle algorithm. In this algorithm, rays are cast downwards from the wheel positions of the chassis, and determine the individual wheel behavior depending on the properties of the ground. This algorithm gives a more realistic behavior than a car build from physics constraints, but also causes some difficulties:

Examples:

function simple_car()
{
  ENTITY* car = ent_create("car.mdl",vector(100,-200,40),NULL); 
  pXent_settype(car,PH_RIGID,PH_BOX);
  ENTITY* FLwheel = ent_create("wheel.mdl",vector(168,-170,17),NULL);
  ENTITY* FRwheel = ent_create("wheel.mdl",vector(168,-230,17),NULL);
  ENTITY* BLwheel = ent_create("wheel.mdl",vector(39,-170,17),NULL);
  ENTITY* BRwheel = ent_create("wheel.mdl",vector(39,-230,17),NULL);
  pXcon_add ( PH_WHEEL, FLwheel, car, 0 );
  pXcon_add ( PH_WHEEL, FRwheel, car, 0 );
  pXcon_add ( PH_WHEEL, BLwheel, car, 0 );
  pXcon_add ( PH_WHEEL, BRwheel, car, 0 );
//drive the car        
  while(1)
  {
    pXcon_setwheel (FLwheel,-5,0,0);
    pXcon_setwheel (FRwheel,-5,0,0); // steer to the right
    pXcon_setwheel (BLwheel,0,500,0);
    pXcon_setwheel (BRwheel,0,500,0);
    wait(1);
  }
}

See also:

Constraints, pXcon_add, pXcon_setparams1, pXcon_setparams2, pXcon_setmotor