Vehicles
Driver Input and Physics Loop
Sends normalized throttle, steering, service-brake and handbrake values to the built native controller.
Set input before jolt_update() in the normal Step event. There is no separate vehicle update method because the VehicleConstraint participates in the native physics step automatically.
Methods#
| Method | Accepted range | Returns |
|---|---|---|
| set_throttle(value) | -1..1 after managed clamp | Boolean |
| set_steering(value) | -1..1 after managed clamp | Boolean |
| set_brake(value) | 0..1 after managed clamp | Boolean |
| set_handbrake(value) | 0..1 after managed clamp | Boolean |
| set_inputs(throttle, steering, brake=0, handbrake=0) | All controls together | Boolean |
// Step event
var throttle = gamepad_axis_value(0, gp_axislv);
var steering = gamepad_axis_value(0, gp_axisrh);
var brake = max(0, gamepad_axis_value(0, gp_axisrv));
var handbrake = gamepad_button_check(0, gp_face1);
if (!car.set_inputs(throttle, steering, brake, handbrake)) {
show_debug_message(jolt_get_error_message());
}
jolt_update();Automatic reverse#
In automatic transmission mode, negative throttle is interpreted by the native controller as reverse input. In manual mode, select a negative gear explicitly with set_gear().
Failure conditions#
- The vehicle has not been built.
- The vehicle, chassis or managed world has been destroyed.
- A low-level caller supplies NaN, infinity or an out-of-range value.
Verified operation contracts#
These contracts distinguish units, return values, errors and lifetime according to the current implementation. Check results: false, 0 and undefined can mean different things for different methods.
| Symbol / owner | Signature | Operation contract |
|---|---|---|
| JoltVehicle.set_inputs | JoltVehicle.set_inputs(throttle,steering,brake=0,handbrake=0) | Built live vehicle; Boolean. Throttle/steering clamp -1..1, brake/handbrake 0..1. Single setters preserve other inputs; set_inputs defaults brakes to 0. |
| JoltVehicle.set_throttle | JoltVehicle.set_throttle(value) | Built live vehicle; Boolean. Throttle/steering clamp -1..1, brake/handbrake 0..1. Single setters preserve other inputs; set_inputs defaults brakes to 0. |