Vehicle¶
Extends EngineObject.
A vehicle on a dynamic body: wheels with suspension and tires, or tracks, an engine and a clutch (Jolt's VehicleConstraint). The game owns the gearbox: it sets DriveRatio (the signed overall ratio it wants, 0 for neutral) and Clutch in the Stepping signal, which runs before each physics step, together with the driver's inputs, and the vehicle gives them to Jolt. Make one with PhysicsWorld.CreateVehicle.
Properties¶
entity: EntityThe entity of the vehicle's body. Read-only.forward: numberThrottle: -1 to 1 (negative backs up in a gearbox that reverses by throttle; the usual gearbox uses DriveRatio's sign).steering: number-1 to 1: positive turns toward +X (the vehicle's left, in its +Z-forward space), negative toward -X.brake: numberhandbrake: numberdrive_ratio: numberThe overall ratio between engine and wheels the game drives through, signed: negative reverses; 0 is neutral. Set it in Stepping.clutch: numberHow far the clutch is engaged: 0 drives nothing, 1 is fully engaged. Set it in Stepping.is_ready: booleanWhether the vehicle is working (its body exists and the wheels were built). Read-only.gear_ratio: numberThe gear ratio the transmission is in now. Read-only.engine_rpm: numberRead-only.engine_torque: numberThe torque the engine gives at the throttle that reached it, in N·m. Read-only.engine_load: numberThe throttle that reached the engine, 0 to 1. Read-only.engine_peak_power_rpm: numberThe rpm where the engine's power (torque times rpm) peaks, from its curve. Read-only.brake_capacity: numberWhat all the brakes give together, in N·m. Read-only.speed_kmh: numberHow fast it moves along its forward axis, in km/h (negative backing up). Read-only.wheel_count: numberHow many wheels it has. Read-only.
Signals¶
stepping: Signal<number>Emitted before each fixed step with its length, before the inputs reach Jolt: the game's driving logic (its gearbox, assists, ABS) belongs here.
Methods¶
get_wheel_contact¶
function get_wheel_contact(self, index: number): boolean
get_wheel_compression¶
function get_wheel_compression(self, index: number): number
How far the suspension is compressed, 0 (extended) to 1.
get_wheel_steer_degrees¶
function get_wheel_steer_degrees(self, index: number): number
How far the wheel is turned about its steering axis, in degrees (positive toward +X, like Steering).
get_wheel_rpm¶
function get_wheel_rpm(self, index: number): number
The wheel's rotation speed in revolutions per minute.
get_wheel_contact_point¶
function get_wheel_contact_point(self, index: number): Vector3
The point where the wheel touches the ground (the world's origin if it does not).
get_wheel_contact_normal¶
function get_wheel_contact_normal(self, index: number): Vector3
get_wheel_contact_entity¶
function get_wheel_contact_entity(self, index: number): Entity
The entity of the body the wheel stands on, or 0.
get_wheel_readings¶
function get_wheel_readings(self): { number }
Four numbers for each wheel, the ones the driving assists need: 1 if it touches the ground (else 0), its angular velocity in rad/s, the load it carries in newtons (its suspension's force) and the grip of its tire (0 for a track's wheel).
set_brake_factor¶
function set_brake_factor(self, index: number, factor: number): ()
Scales one wheel's brake torque for the next steps: 0 releases it, 1 is full. An ABS sets it every step.
get_brake_factor¶
function get_brake_factor(self, index: number): number