‹›
Character

Creating Character

Creates and manages a capsule-based CharacterVirtual controller in the default physics world.

jolt_character() creates a managed JoltCharacter. Its public position is the capsule base at the character's feet, its total height includes both rounded ends, and +Z is up unless a reference frame changes it.

Syntax#

Syntax
jolt_character(x, y, z, options=undefined)

Minimal setup#

GML
jolt_start();

var player = jolt_character(0, 0, 1, {
    radius: 0.4,
    height: 1.8,
    layer: jolt_default_layer()
});

if (is_undefined(player)) {
    show_error(jolt_get_error().message, true);
}

Options#

FieldDefaultMeaning
radius0.4Capsule radius; must be greater than 0.
height1.8Total standing height; must exceed 2 × radius.
crouch_heightmax(2 × radius + 0.05, height × 0.62)Total crouching height.
mass80Positive character mass.
max_strength100Maximum force used to interact with bodies.
speed5Planar movement speed.
jump_speed7Velocity added along the current up vector.
gravity9.81Positive gravity magnitude.
max_slope45Maximum walkable angle in degrees.
step_height0.35Maximum stair step-up distance.
layerDefaultLive collision layer from the default world.
coyote_time0Seconds in which a late jump may still start.
jump_buffer0Seconds for which an early jump request is retained.

Lifetime and identity#

GML
player.is_valid()
player.get_native_handle()
jolt_managed_character_count()
player.destroy()

destroy() removes the native controller, invalidates the managed wrapper, clears bindings and contact arrays, and makes later operations fail safely.

Binding a GameMaker instance#

GML
player.bind_instance(id);

// After jolt_update():
player.sync();

sync() copies x, y, z, jolt_ground_state, and jolt_is_crouched to the bound instance. unbind_instance() removes the mapping without destroying the character.

Configure after creation#

GML
player = jolt_character();
if (!is_undefined(player)) {
    player.set_position(0, 0, 2);
    player.set_radius(0.4);
    player.set_height(2.0);
}

Height is the full capsule and position denotes the feet. Resizing is immediate and returns false on invalid values or blockage. crouch_height preserves its proportion.

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_characterjolt_character(x = 0, y = 0, z = 0, options = undefined)JoltCharacter or undefined; requires a running managed world. Feet position (m) defaults to 0. Options: radius=.4, height=1.8 (total), crouch_height=max(2*radius+.05, height*.62), mass=80 kg, max_strength=100 N, speed=5 m/s, jump_speed=7 m/s, gravity=9.81 m/s², max_slope=45°, step_height=.35 m, default layer, coyote_time=jump_buffer=0 s. max_push_force is only a fallback option for max_strength. Unknown options do not create setters; configure air/ground friction through methods.
JoltCharacter.bind_instanceJoltCharacter.bind_instance(instance)bind_instance requires an existing GameMaker instance and returns Boolean; unbind_instance returns true. Does not own the instance or automatically change user_data.
JoltCharacter.destroyJoltCharacter.destroy()Boolean; destroys the Character and its Grip, not its attachment host or GameMaker instance. Repetition after success returns true.
JoltCharacter.get_collide_with_back_facesJoltCharacter.get_collide_with_back_faces()Default true: both sides of mesh triangles; false front faces only. Setter Boolean success, getter Boolean state (also false on error).
JoltCharacter.get_native_handleJoltCharacter.get_native_handle()Live Character handle, otherwise 0; not a rigid Body handle.
JoltCharacter.get_positionJoltCharacter.get_position()World feet position {x, y, z} in m; undefined on error.
JoltCharacter.get_radiusJoltCharacter.get_radius()Stored current dimension in m; height is total, not cylinder height. Getter does not itself validate liveness.
JoltCharacter.get_user_dataJoltCharacter.get_user_data()Any GML value stored in the wrapper; setter true, getter returns the value. Not a native physics parameter; ownership of the stored object is not transferred.
JoltCharacter.get_view_transformJoltCharacter.get_view_transform(yaw, pitch)Finite yaw/pitch in degrees; returns {position, target, up}, undefined on error. Eye is feet + up*current height. Attached angles are relative to the host, otherwise world-space.
JoltCharacter.is_validJoltCharacter.is_valid()Boolean, checks wrapper, original world and native handle.
JoltCharacter.just_stoodJoltCharacter.just_stood()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_collide_with_back_facesJoltCharacter.set_collide_with_back_faces(enabled)Default true: both sides of mesh triangles; false front faces only. Setter Boolean success, getter Boolean state (also false on error).
JoltCharacter.set_positionJoltCharacter.set_position(x, y, z)Finite world feet position x/y/z in m; Boolean. Teleport clears transport and external impulse state. Rejected while attached.
JoltCharacter.set_radiusJoltCharacter.set_radius(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.set_user_dataJoltCharacter.set_user_data(value)Any GML value stored in the wrapper; setter true, getter returns the value. Not a native physics parameter; ownership of the stored object is not transferred.
JoltCharacter.syncJoltCharacter.sync()Boolean; copies current position into the bound live GameMaker instance. False without a live binding or Character.
JoltCharacter.unbind_instanceJoltCharacter.unbind_instance()bind_instance requires an existing GameMaker instance and returns Boolean; unbind_instance returns true. Does not own the instance or automatically change user_data.