Bodies

Box

Creates a box aligned with the body's local axes.

Use it for crates, walls, floors, and simple objects. x, y, and z are the world-space centre. Dynamic, Static, and Kinematic are supported.

Syntax#

Syntax
jolt_box_create_dynamic(x, y, z, width, depth, height, options=undefined)
jolt_box_create_static(x, y, z, width, depth, height, options=undefined)
jolt_box_create_kinematic(x, y, z, width, depth, height, options=undefined)

Instance helper#

GML
jolt_box_create_dynamic_for_instance(instance, width, depth, height, options=undefined)

Arguments#

ArgumentTypeDescription
x, y, zRealWorld-space centre.
widthRealFull X size; finite and > 0.
depthRealFull Y size; finite and > 0.
heightRealFull Z size; finite and > 0.
optionsStructOptional shared body options.

Return and behaviour#

Returns a JoltBody or undefined. It supports the standard JoltBody properties, collision layers, sensor mode, contacts, and raycasts; motion-type restrictions still apply to forces, mass, and velocity. Invalid positions, dimensions, options, or native shape creation are rejected. The pivot stays centred; rotation can be supplied through options or body methods. Debug draw uses the full dimensions and transform.

Reusable JoltShape#

GML
var shape = jolt_shape_box(width, depth, height, cache_key=undefined);
var dynamic_body = shape.create_dynamic(x, y, z, options);
var static_body = shape.create_static(x, y, z, options);
var kinematic_body = shape.create_kinematic(x, y, z, options);

Dimensions must be finite and positive. cache_key is ASCII up to 255 characters. Resources can be shared; shape.destroy() is idempotent and created bodies retain their native reference. jolt_shape_load(path, cache_key) supports valid Box .jcol assets.

Example#

GML
jolt_start();
var floor = jolt_box_create_static(0, 0, -0.5, 20, 20, 1, {friction:0.8});
var crate = jolt_box_create_dynamic(0, 0, 4, 1, 1, 1, {mass:2, restitution:0.1});

The floor's top is at Z=0 and the Dynamic crate falls onto it during simulation.

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_box_create_dynamic_for_instancejolt_box_create_dynamic_for_instance(instance, width, depth, height, options = undefined)Creates a Dynamic box for an existing instance and binds it; returns JoltBody/undefined. Use explicit sync to write physics transform into the instance.