‹›
Current project

Mouse interaction with controls

Operate all nine physical control types without changing their limits, springs, resistance, detents or motors. Forces/torques run before fixed physics steps; dynamic mounts receive reaction.

Example#

GML
interaction = jolt_control_interaction();
interaction.set_camera(o_control_bbmod_camera);
interaction.set_carry(carry);
interaction.set_distance(3);
interaction.set_sensitivity(0.35);
interaction.set_max_force(200);
interaction.set_max_torque(20);
// End Step:
if (!interaction.update_controls()) carry.update_controls();

Usage and limits#

Camera Step must test interaction.controls_use_mouse(id) before consuming mouse-look. Carry has priority when holding an item. Initial ray hit acquires capture; moving the ray away does not release. Mouse-up, focus loss, distance, lock, destruction or stale input releases; acquiring again requires a new click.

Button defaults to press/hold; set_button_mode("drag") uses its projected axis. Lever, Pedal, Slider and Pull Handle use visible movement direction. Knob and Hand Wheel retain their initial turning direction; Crank follows the changing handle tangent and needs circular movement. Joystick projects two axes within its physical cone. Approach sliders/handles obliquely if looking along their stroke.

For custom input use jolt_control_interaction_frame(origin,forward,up), begin_from_hit(hit,frame), then update_drag(frame,dx,dy,held,dt_seconds) with a fresh complete raycast result. Own the filtering and do not also run the automatic adapter. Destroy interaction in Clean Up.

API reference#

Public function and method signatures. Call methods on the returned instance; parameters with defaults are optional.

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
jolt_control_interactionjolt_control_interaction()Requires started world; JoltControlInteraction or undefined. Defaults enabledtrue, distance3m, sensitivity.35, max_force200N, max_torque20N·m, max_lead15°, left button, press mode.
jolt_control_interaction_framejolt_control_interaction_frame(origin,forward,up)World origin + nonzero independent forward/up XYZ structs; returns orthonormal {origin, forward, right, up}, undefined on error.
JoltControlInteraction.begin_from_hitJoltControlInteraction.begin_from_hit(hit,frame)Fresh raycast hit + frame → Boolean. Checks reach, supported unlocked same-world control and exclusive ownership; can reject an unprojectable axis.
JoltControlInteraction.controls_use_mouseJoltControlInteraction.controls_use_mouse(view)In Camera Step before yaw/pitch changes; Boolean whether click/drag belongs to this control. Can begin interaction from a new click.
JoltControlInteraction.destroyJoltControlInteraction.destroy()Returns true; releases interaction ownership, destroy also invalidates controller. Does not destroy the mechanism.
JoltControlInteraction.get_controlJoltControlInteraction.get_control()is_active Boolean, releases on lost validity; get_control active borrowed JoltControl or undefined.
JoltControlInteraction.is_activeJoltControlInteraction.is_active()is_active Boolean, releases on lost validity; get_control active borrowed JoltControl or undefined.
JoltControlInteraction.releaseJoltControlInteraction.release()Returns true; releases interaction ownership, destroy also invalidates controller. Does not destroy the mechanism.
JoltControlInteraction.set_buttonJoltControlInteraction.set_button(v)Boolean success. enabled Boolean (false releases), mode press/drag (releases), button integer0..5 (0 disables, change releases).
JoltControlInteraction.set_button_modeJoltControlInteraction.set_button_mode(v)Boolean success. enabled Boolean (false releases), mode press/drag (releases), button integer0..5 (0 disables, change releases).
JoltControlInteraction.set_cameraJoltControlInteraction.set_camera(v)Boolean; same-world carry exposing is_holding or undefined; camera object/instance/undefined. Replacement releases interaction. An actively holding carry blocks interaction.
JoltControlInteraction.set_carryJoltControlInteraction.set_carry(v)Boolean; same-world carry exposing is_holding or undefined; camera object/instance/undefined. Replacement releases interaction. An actively holding carry blocks interaction.
JoltControlInteraction.set_distanceJoltControlInteraction.set_distance(v)Boolean; finite method-specific ranges: .05..100 m, .001..10 sensitivity, 0..100000 N, 0..100000 N·m, 1..45°.
JoltControlInteraction.set_enabledJoltControlInteraction.set_enabled(v)Boolean success. enabled Boolean (false releases), mode press/drag (releases), button integer0..5 (0 disables, change releases).
JoltControlInteraction.set_max_forceJoltControlInteraction.set_max_force(v)Boolean; finite method-specific ranges: .05..100 m, .001..10 sensitivity, 0..100000 N, 0..100000 N·m, 1..45°.
JoltControlInteraction.set_max_leadJoltControlInteraction.set_max_lead(v)Boolean; finite method-specific ranges: .05..100 m, .001..10 sensitivity, 0..100000 N, 0..100000 N·m, 1..45°.
JoltControlInteraction.set_max_torqueJoltControlInteraction.set_max_torque(v)Boolean; finite method-specific ranges: .05..100 m, .001..10 sensitivity, 0..100000 N, 0..100000 N·m, 1..45°.
JoltControlInteraction.set_sensitivityJoltControlInteraction.set_sensitivity(v)Boolean; finite method-specific ranges: .05..100 m, .001..10 sensitivity, 0..100000 N, 0..100000 N·m, 1..45°.
JoltControlInteraction.update_controlsJoltControlInteraction.update_controls()Once after camera; returns whether Control claimed this click/hold so Carry skips the same input. Not simply is_active or confirmation of motion.
JoltControlInteraction.update_dragJoltControlInteraction.update_drag(frame,dx,dy,held,dt=0.016666667)Frame, dx/dy pixels, held, dt>0 s (default 1/60). Boolean; held=false, invalid geometry or out-of-reach releases. Applies physical forces in the subsequent step, no pose writes.