‹›
Vehicles

Runtime State and Getters

Reads built vehicle speed, drivetrain state and wheel count without duplicating the native simulation in GML.

Runtime getters require a live built vehicle except get_wheel_count(), which returns the managed draft count while the wrapper remains valid.

Vehicle getters#

MethodReturn value
is_valid()Boolean native/wrapper validity check.
get_speed()Non-negative magnitude of chassis world linear velocity.
get_forward_speed()Signed chassis velocity along its current local +Y direction.
get_engine_rpm()Current native engine RPM.
get_current_gear()Negative reverse, zero neutral, positive forward.
get_engine_state(){rpm, gear, clutch, switching}.
get_wheel_count()Number of wheels added to the managed vehicle.
get_wheel(index)Complete wheel snapshot or undefined.
get_wheel_transform(index){position, rotation} or undefined.
GML
var state = car.get_engine_state();
show_debug_message("speed=" + string(car.get_forward_speed())
    + " rpm=" + string(state.rpm)
    + " gear=" + string(state.gear));

Speed interpretation#

  • get_speed() measures motion in any world direction, including sideways or vertical movement.
  • get_forward_speed() is signed and rotates with the chassis, making it suitable for forward/reverse logic.
  • Neither value is wheel angular speed; use get_wheel(index).angular_velocity for individual wheels.

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 / ownerSignatureOperation contract
JoltVehicle.get_current_gearJoltVehicle.get_current_gear()Numeric RPM or gear index according to method; undefined on error/unbuilt vehicle.
JoltVehicle.get_engine_stateJoltVehicle.get_engine_state()Returns {rpm, gear, clutch, switching}. Even on failure a struct can exist with undefined numeric fields and switching=false; the struct alone does not prove validity.
JoltVehicle.get_forward_speedJoltVehicle.get_forward_speed()Number in m/s or undefined on error; speed is magnitude, forward_speed is the signed forward component. Requires build.
JoltVehicle.get_speedJoltVehicle.get_speed()Number in m/s or undefined on error; speed is magnitude, forward_speed is the signed forward component. Requires build.
JoltVehicle.get_wheel_countJoltVehicle.get_wheel_count()Number of wheels recorded by the GML wrapper, works before build; invalid wrapper returns 0.