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#
jolt_character(x, y, z, options=undefined)Minimal setup#
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#
| Field | Default | Meaning |
|---|---|---|
| radius | 0.4 | Capsule radius; must be greater than 0. |
| height | 1.8 | Total standing height; must exceed 2 × radius. |
| crouch_height | max(2 × radius + 0.05, height × 0.62) | Total crouching height. |
| mass | 80 | Positive character mass. |
| max_strength | 100 | Maximum force used to interact with bodies. |
| speed | 5 | Planar movement speed. |
| jump_speed | 7 | Velocity added along the current up vector. |
| gravity | 9.81 | Positive gravity magnitude. |
| max_slope | 45 | Maximum walkable angle in degrees. |
| step_height | 0.35 | Maximum stair step-up distance. |
| layer | Default | Live collision layer from the default world. |
| coyote_time | 0 | Seconds in which a late jump may still start. |
| jump_buffer | 0 | Seconds for which an early jump request is retained. |
Lifetime and identity#
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#
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#
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 / owner | Signature | Operation contract |
|---|---|---|
| jolt_character | jolt_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_instance | JoltCharacter.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.destroy | JoltCharacter.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_faces | JoltCharacter.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_handle | JoltCharacter.get_native_handle() | Live Character handle, otherwise 0; not a rigid Body handle. |
| JoltCharacter.get_position | JoltCharacter.get_position() | World feet position {x, y, z} in m; undefined on error. |
| JoltCharacter.get_radius | JoltCharacter.get_radius() | Stored current dimension in m; height is total, not cylinder height. Getter does not itself validate liveness. |
| JoltCharacter.get_user_data | JoltCharacter.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_transform | JoltCharacter.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_valid | JoltCharacter.is_valid() | Boolean, checks wrapper, original world and native handle. |
| JoltCharacter.just_stood | JoltCharacter.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_faces | JoltCharacter.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_position | JoltCharacter.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_radius | JoltCharacter.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_data | JoltCharacter.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.sync | JoltCharacter.sync() | Boolean; copies current position into the bound live GameMaker instance. False without a live binding or Character. |
| JoltCharacter.unbind_instance | JoltCharacter.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. |