Vehicles
Vehicles
Creates a native Jolt Physics 5.6 wheeled vehicle around an ordinary Dynamic JoltBody chassis.
JoltVehicle owns a VehicleConstraint, WheeledVehicleController and virtual wheels. Jolt solves suspension, tyre forces, drivetrain and contacts inside jolt_update(); GameMaker owns input and rendering.
What a vehicle contains#
- One existing Dynamic, non-sensor JoltBody used as the chassis.
- Two to thirty-two virtual wheels. Wheels are not separate rigid bodies.
- Per-wheel suspension, steering, drive and brake configuration.
- A native engine, transmission, one or more differentials and optional anti-roll bars.
- A wheel collision tester that finds ground through the chassis collision layer.
Coordinate convention#
| Axis | Vehicle meaning |
|---|---|
| X | Chassis left/right. Wheel axle direction for rendering. |
| Y | Chassis forward/backward. Local +Y is forward. |
| Z | Up/down. Suspension normally travels along local -Z. |
Recommended workflow#
var chassis = jolt_box_create_dynamic(...);
var car = jolt_vehicle(chassis, options);
car.add_wheel(...);
car.add_wheel(...);
car.build();
// Step event
car.set_inputs(throttle, steering, brake, handbrake);
jolt_update();Important ownership rules#
- The vehicle reuses its chassis; it does not own the GameMaker variable or render model.
- Vehicle configuration is a draft until build() and becomes immutable after a successful build.
- Destroying the chassis invalidates its dependent vehicle. jolt_stop() destroys vehicles before bodies and the world.
- Use is_valid() before retaining a vehicle across uncertain lifetime boundaries.