Character

Crouching

Switches between standing and crouching capsules with an automatic clearance test.

crouch(true) requests the shorter capsule. crouch(false) attempts to restore the standing capsule during the next fixed step and refuses to stand when rigid geometry blocks the required space.

Changing stance#

GML
player.crouch(keyboard_check(vk_control));
jolt_update();

if (player.just_crouched()) {
    // Enter crouch animation.
}

if (player.stand_was_just_blocked()) {
    // Keep the crouch animation under a low ceiling.
}

State methods#

MethodMeaning
is_crouched()Current native stance.
just_crouched()Standing changed to crouching during this update.
just_stood()Crouching changed to standing during this update.
was_stand_blocked()The latest stand request failed its clearance test.
stand_was_just_blocked()A stand request first became blocked during this update.

Dimensions#

GML
var radius = player.get_radius();
var standing = player.get_standing_height();
var crouched = player.get_crouch_height();
var current = player.get_current_height();

Both shapes share one radius and remain anchored at the same feet position. The configured heights are total capsule heights, including the rounded ends.

Event lifetime#

Stance transition and newly-blocked flags are reset once per jolt_update(). Query persistent methods such as is_crouched() or was_stand_blocked() when you need current state rather than a one-frame event.

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
JoltCharacter.crouchJoltCharacter.crouch(enabled)Boolean success submitting a request (input evaluated as true/false). Actual stance change happens in a solver step and can be blocked by geometry.
JoltCharacter.get_crouch_heightJoltCharacter.get_crouch_height()Stored current dimension in m; height is total, not cylinder height. Getter does not itself validate liveness.
JoltCharacter.get_current_heightJoltCharacter.get_current_height()Current total height in m according to is_crouched. A crouch-query error can return standing_height; check validity first.
JoltCharacter.get_standing_heightJoltCharacter.get_standing_height()Stored current dimension in m; height is total, not cylinder height. Getter does not itself validate liveness.
JoltCharacter.is_crouchedJoltCharacter.is_crouched()Boolean latest native state; also false on error. was_stand_blocked is not the one-frame stand_was_just_blocked event.
JoltCharacter.just_crouchedJoltCharacter.just_crouched()Boolean event for the managed frame; read after jolt_update. The next managed frame begin clears it. Not persistent state (e.g. just_landed is not is_grounded).
JoltCharacter.set_heightJoltCharacter.set_height(metres)Finite capsule dimensions in m, radius>0, total height>2*radius+minimum cylinder section. Boolean; changes immediately, blocked/attached changes fail without changing dimensions. Crouch height follows the original ratio with a radius-based minimum.
JoltCharacter.stand_was_just_blockedJoltCharacter.stand_was_just_blocked()Boolean event for the managed frame; read after jolt_update. The next managed frame begin clears it. Not persistent state (e.g. just_landed is not is_grounded).
JoltCharacter.was_stand_blockedJoltCharacter.was_stand_blocked()Boolean latest native state; also false on error. was_stand_blocked is not the one-frame stand_was_just_blocked event.