The main physics script for ground vehicles like cars and hovercraft, also used by the car templates. Contains a startup function that activates the PhysX engine and establishes a default setting for racing games. The script is automatically included when adding the car template (t_car.h), and all default parameters can be adjusted in this template.
Parameter | Default | Remarks |
tcar_gravity | 50 |
Gravity factor. |
tcar_facBrake | 4 |
Car brake power in multiples of the car's motor power (car_maxTorque) |
tcar_facSteer | 2 |
Steer angle increase in degrees per tick. |
tcar_dampSteer | 80 |
Steer angle reduction at high speed, in percent. |
tcar_crashSpeed | 20 |
Crash speed, plays crash sound when abruptly stopped above this speed (km/h). |
engine_wav | "engine.ogg" |
Engine sound, loopable. |
tires_wav | "tires.wav" |
Tire screech sound, loopable. |
crash_wav | "crash.ogg" |
Crash sound. |
horn_wav | "horn.wav" |
Horn sound, loopable. |
key_forward | "cuu" |
Accelerator. |
key_backward | "cud" |
Accelerator, reverse gear. |
key_left | "cul" |
Steer left. |
key_right | "cur" |
Steer right. |
key_brake | "space" |
Full brake. |
key_horn | "h" |
Sound the horn. |
key_lift | "l" |
Upwards kick for lifting a toppled car. |
Skill/Flag | Name | Default | Remarks |
FLAG1 | car_hover | 0 | Set this flag for a hovercraft (invisible wheels). |
skill1 | car_maxSpeed | 200 | Car Maximum Speed, in km/h on even road. When the car approaches this speed, the motor torque is automatically reduced. The car can exceed this speed a little when driving downhill or receiving heavy tail wind. |
skill2..4 | car_wheel_fx/y/z | 40,20,-14 | Offset of the front wheels from the car center. Scaled with the car scale. |
skill5..7 | car_wheel_rx/y/z | -34,20,-14 | Offset of the rear wheels from the car center. Scaled with the car scale. |
skill8 | car_wheelDrive | 1 | 1 = Rear wheel drive, 2 = Front wheel drive, 3 = 4-wheel drive. |
skill9 | car_maxTorque | 1000 | Motor Power, maximum torque applied to the driven wheels (automatically reduced at high speed). |
skill10 | car_maxSteer | 40 | Maximum Steer Angle, determines the turning circle (automatically reduced at high speed). |
skill11 | car_massFactor | 100 | Car Mass Factor - multiplies the car volume mass with the given percentage. |
skill12 | car_massOffset | -100 | Car Mass Offset - vertical offset of the mass center in percent. Place the center low to avoid that the car topples in fast curves. |
skill13 | car_massShape | 100 | Car Mass Shape - inertia tensor x component, determines the inertia for rolling about the car's length axis. Make this small for elongated cars (like dragsters) or high for less toppling. |
skill14 | car_spsSpring | 300 | Suspension Spring element - fine tune the spring stiffness according to the car's weight. |
skill15 | car_spsDamper | 100 | Suspension Damper element - increase this for reducing bumpiness. |
skill16 | car_spsWay | 10 | Suspension Way in quants - increase this for large wheels or monster trucks. |
skill18 | car_frictionWheel | 100 | Wheel Longitudinal Friction - friction factor in forward direction, affects acceleration and braking. |
skill19 | car_frictionLatF | 200 | Front Wheel Lateral Friction - sidewards friction factor, affects steering. |
skill20 | car_frictionLatR | 200 | Rear Wheel Lateral Friction - sidewards friction factor, affects power sliding in curves. |
skill61 | car_torque | Current motor power (can be set by an external AI function; automatically reduced at high speed). | |
skill62 | car_brake | Current brake power (can be set by an external AI function; automatically applied when the car rolls forward and reverse gear is hit). | |
skill63 | car_steerangle | Current steer angle (can be set by an external AI function; automatically reduced at high speed). | |
skill66 | actor_id | Unique number to identify the entity (1357 == car) | |
skill71 | car_speed | Current speed of the car in km/h; can be read by external functions, f.i. from the speedometer in t_car_props.c. | |
skill75 | car_wheelFL | Pointer of the front left wheel entity; can be used for effects or for individually adjusting the ground friction. | |
skill76 | car_wheelFR | Pointer of the front right wheel entity. | |
skill77 | car_wheelRL | Pointer of the rear left wheel entity. | |
skill78 | car_wheelRR | Pointer of the rear right wheel entity. |
action vehicle1() { my.flags |= SHADOW; my.car_maxSpeed = 80; my.car_maxTorque = 500; my.car_spsSpring = 150; my.car_spsDamper = 30; my.car_massOffset = -60; my.car_frictionLatR = 150; // wheel positions can be determined from the MED status line: my.car_wheel_fx = 23.5; my.car_wheel_rx = -26; my.car_wheel_fy = 21; my.car_wheel_ry = 21; my.car_wheel_fz = -10; my.car_wheel_rz = -11; my.car_spsWay = 7; // for suspension animation car_player(); }