Button
Button is a short linear push button with a separate pressed state and hysteresis.
jolt_control_button(options=undefined)Call jolt_start() before creation. Every factory accepts one optional options struct and returns JoltControl, or undefined on error. Common options: parent, position/rotation or local_position/local_rotation, mass, resistance and output. Dimensions are full lengths in metres, mass is in kg; this API uses degrees for angles. See Mounting, Size and Rendering for shared configuration.
| Item | Meaning / default |
|---|---|
| cap_size | {x:0.12, y:0.12, z:0.03} |
| mass / travel | 0.15 kg / 0.02 m |
| initial_value | 0 (0..1) |
| auto_return / target | false / 0 |
| pressed_threshold / released_threshold | 0.8 / 0.6 |
| drive | {max_force:12, frequency:12, damping:1} |
| detents | [] |
The origin is the released cap centre. +Z points outward and pressing moves along −Z; get_value() returns 0 at rest and 1 at the travel end. is_pressed() turns on at pressed_threshold and turns off only after falling to released_threshold. Require 0 ≤ released_threshold < pressed_threshold ≤ 1. This method exists only on Button.
target is a canonical value in 0..1. set_target() alone only stores the target; enable the drive with auto_return: true or set_auto_return(true). The body moves towards it physically; creation does not place the body at target.
Example#
button = jolt_control_button({auto_return: true, target: 0});
// After simulation; initialize was_pressed to false once.
var pressed = button.is_pressed();
if (pressed && !was_pressed) show_debug_message("Activate");
was_pressed = pressed;Current project integrations#
New related workflows#
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_control_button | jolt_control_button(options=undefined) | Requires managed world, optional options, returns owning JoltControl or undefined. Without parent world position/rotation; with parent local_position/local_rotation, do not mix. Button: cap_size .12/.12/.03 m, mass .15 kg, travel .02 m, initial0, thresholds .8/.6, auto_return false, target0. Motion -Z. |
| JoltControl.is_pressed | JoltControl.is_pressed() | Only Button has this method; Boolean with pressed/released hysteresis, also false on error. |