‹›
Utility Scripts · Physical Controls

Angle, Turns, Phase and Zero

Read actual multi-turn Wheel/Crank position and change logical zero without moving the body.

ItemMeaning / default
get_angle()Continuous logical angle in degrees, positive or negative.
get_turns()Whole turns truncated towards zero; −90° has 0 turns.
get_phase() / get_value()Phase [0,1) using floor modulo; −90° has phase 0.75.
get_speed()Actual relative speed about the axis in °/s, unlike body API rad/s.
set_zero()Makes the current position logical zero; returns true/false.

Example#

GML
var angle = wheel.get_angle();
var turns = wheel.get_turns();
var phase = wheel.get_phase();
var speed = wheel.get_speed();
if (keyboard_check_pressed(ord("Z"))) wheel.set_zero();

Zeroing preserves physical pose, velocity and stored speed/torque. It clears existing detent capture, re-resolves the phase target, and absolute numeric targets continue to apply relative to the new zero. With a position motor enabled, zeroing may therefore change the physical point it drives towards.

Simulation step and precision#

Tracking requires dt × the sum of both endpoint angular bounds < 135° over the whole sampled physics update. Dynamic endpoints use max angular velocity; Kinematic endpoints use prescribed velocity. More collision substeps alone do not bypass this condition. For example, the default dynamic bound of roughly 2700°/s rejects dt=0.1 s for a free wheel even if its motor requests zero. Use the normal jolt_update() loop with a suitable fixed step.

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
JoltControl.get_angleJoltControl.get_angle()Wheel/Crank only: multi-turn angle ° / turns / phase 0..1 / speed °/s. Number or undefined on invalidity or incompatible type.
JoltControl.get_phaseJoltControl.get_phase()Wheel/Crank only: multi-turn angle ° / turns / phase 0..1 / speed °/s. Number or undefined on invalidity or incompatible type.
JoltControl.get_speedJoltControl.get_speed()Wheel/Crank only: multi-turn angle ° / turns / phase 0..1 / speed °/s. Number or undefined on invalidity or incompatible type.
JoltControl.get_turnsJoltControl.get_turns()Wheel/Crank only: multi-turn angle ° / turns / phase 0..1 / speed °/s. Number or undefined on invalidity or incompatible type.
JoltControl.set_zeroJoltControl.set_zero()Wheel/Crank only, Boolean. Sets logical encoder zero; does not rotate the physical body.