Input/Output Demo Controller
A demonstration controller that showcases how to read vehicle inputs and write to electrics outputs. Useful as a learning reference for controller development — shows the input/output pipeline without complex logic.
A demonstration controller that showcases how to read vehicle inputs and write to electrics outputs. Useful as a learning reference for controller development — shows the input/output pipeline without complex logic.
State Fields
| Field | Type | Description |
|---|---|---|
type | string | Keep as "auxiliary", there is also "main", but for logging purposes that would be the wrong choice |
defaultOrder | number | This determines when the controller update methods are executed relative to other controllers. If you have no specific requirements to that order, it's not relevant |
Public API
| Function | Description |
|---|---|
saveLogToCSV() | If you want to expose your own methods to the outside (for example for calling upon a key press) you need to list them here in the following format. There's an external and an internal name, the external is what the outside world sees, the internal is what your method in this file needs to be called like. (Both names can be the same) If this controller code is active (ie. specified in jbeam) you can call this method like this: controller.getController("loggerTemplate").saveLogToCSV() External name Internal name |
Hooks
| Hook | Description |
|---|---|
init() | This is called once when a vehicle is created |
reset() | This is being called once after the vehicle is created and then once everytime when the vehicle is reset |
updateGFX(dt) | This runs at a variable update rate matching the current FPS Example: The game runs at 60fps: Emthod is being called 60 times per second (and the dt variable is ~1/60 = 0.166667s) If you overload this method performance wise, fps will drop gracefully, so disk IO and other heavily unpredictable things are done/triggered from here (or user input) |
updateFixedStep(dt) | This runs at a fixed 100hz. (derived from 2000hz physics step, see note about performance on update()) |
update(dt) | This runs at a fixed 2000hz. Note: Fixed 2000hz means that there is ever only 0.0005s or 0.5ms of computing time available for all work. That includes all the raw physics, large parts of the powertrain, some parts of the safety and driving electronics, etc As soon as your computer takes more than the 0.5ms to process all these things, the game will not be able to compute things in time anymore and it will enter an automatic slow motion mode In practice this means that you should be very well aware of how performance sensitive your code is and avoid uunpredictable things like disk IO in anything that is/derives from the 2000hz update |
See Also
- Controller Template — Boilerplate for new controllers
- Logger Template — Data logging template
Hydraulic Suspension Controller
Controls hydraulic ride height adjustment systems. Manages pump pressure, valve states, and target heights for each corner of the vehicle. Used on lowriders, air-ride equipped vehicles, and utility vehicles with load-leveling.
JATO (Jet Assisted Take-Off)
Controls rocket-powered JATO boosters that apply massive thrust to the vehicle. Manages fuel consumption, thruster node forces, and particle/sound effects. Includes a hidden cheat sequence for infinite fuel mode.