Differentials and Drive Layouts
Connects engine torque to one or two wheel indices and controls final ratio, left/right split and limited slip.
Explicit differentials support FWD, RWD and AWD layouts. If none are added, build() groups wheels marked driven into practical automatic differentials.
Syntax#
vehicle.add_differential(left_wheel, right_wheel, options=undefined)| Option | Default | Validation |
|---|---|---|
| ratio | 3.42 | Finite and greater than 0. |
| split | 0.5 | Left/right torque split from 0 to 1. |
| limited_slip_ratio | 1.4 | Finite and greater than 1. |
| engine_torque_ratio | 1.0 | Share of engine torque from 0 to 1. |
Layouts#
// Rear-wheel drive
car.add_differential(2, 3, { engine_torque_ratio:1 });
// All-wheel drive: split engine torque between axles
car.add_differential(0, 1, { engine_torque_ratio:0.45 });
car.add_differential(2, 3, { engine_torque_ratio:0.55 });- Each wheel index must exist. -1 may represent an absent side, but both sides cannot be absent.
- Explicit differential calls must occur before build().
- With automatic generation, driven wheels are paired in insertion order and torque is shared across the generated pairs.
- A wheel's driven snapshot reflects its driven flag; explicit differential membership is separate configuration.
Configuration object and setters#
var differential = jolt_vehicle_differential(0, 1);
differential.set_ratio(3.42);
differential.set_split(0.5);
car.add_differential(differential);Configuration factories return a GML settings object and create no physics. Their setters return self, the settings object, and do not confirm that a value is valid. Fields are consumed and validated by jolt_vehicle, add_wheel or add_differential. An omitted field preserves the corresponding options default described above. Editing settings after consumption does not change an existing vehicle, wheel or differential. Settings need no destroy.
Vehicle creation returns undefined on failure. add_differential returns Boolean; add_wheel returns a numeric zero-based index or Boolean false on failure. Index 0 is success: do not use only if (!wheel_index). Complete wheel/differential configuration before build().
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 |
|---|---|---|
| jolt_vehicle_differential | jolt_vehicle_differential(left, right) | Creates settings with left/right wheel indices; a negative index denotes a missing side, at least one must exist when added. Returns settings, not a simulated differential. |
| JoltVehicle.add_differential | JoltVehicle.add_differential(left, right = undefined, options = undefined) | Before build; wheel indices + options or DifferentialSettings. Boolean. Ratio >0, split/engine fraction 0..1, limited slip >1; one side may be negative. |
| JoltVehicleDifferentialSettings.set_engine_torque_ratio | JoltVehicleDifferentialSettings.set_engine_torque_ratio(value) | Pre-creation configuration; returns self, validation deferred to jolt_vehicle/add_wheel/add_differential. Fraction 0..1, default 1. |
| JoltVehicleDifferentialSettings.set_limited_slip_ratio | JoltVehicleDifferentialSettings.set_limited_slip_ratio(value) | Pre-creation configuration; returns self, validation deferred to jolt_vehicle/add_wheel/add_differential. Ratio > 1, default 1.4. |
| JoltVehicleDifferentialSettings.set_ratio | JoltVehicleDifferentialSettings.set_ratio(value) | Pre-creation configuration; returns self, validation deferred to jolt_vehicle/add_wheel/add_differential. Ratio > 0, default 3.42. |
| JoltVehicleDifferentialSettings.set_split | JoltVehicleDifferentialSettings.set_split(value) | Pre-creation configuration; returns self, validation deferred to jolt_vehicle/add_wheel/add_differential. Left/right split 0..1, default 0.5. |