jolt_box_create_static
Creates a Static box in the default physics world.
Call jolt_start() successfully first. Dimensions are full lengths along the body's local axes; the position uses world-space Z-up coordinates.
Syntax#
jolt_box_create_static(x=0, y=0, z=0, width=1, depth=1, height=1, options=undefined);All arguments may be omitted: this creates a unit box at the origin. Then use set_position and set_rotation_euler; geometry setters must match the shape type.
| Argument | Type | Description |
|---|---|---|
| x | Real | Finite world-space X coordinate of the body centre; Z points up. |
| y | Real | Finite world-space Y coordinate of the body centre; Z points up. |
| z | Real | Finite world-space Z coordinate of the body centre; Z points up. |
| width | Real | Full size along local X; finite and greater than zero. |
| depth | Real | Full size along local Y; finite and greater than zero. |
| height | Real | Full size along local Z; finite and greater than zero. |
| options | Struct | undefined | OPTIONAL. Defaults to undefined. Shared body settings; see Bodies Overview. |
Returns#
JoltBody | undefined. Success returns a managed body. Invalid dimensions, position or options, and native creation failures return undefined. Read jolt_get_error() immediately.
Lifetime#
The caller owns the body. Call body.destroy() when it is no longer needed; jolt_stop() tears down the managed world. No rendering object is created.
Example#
Place the code in the object's Create and Cleanup events as marked. The world must exist when creating and destroying the body; update it once per frame with jolt_update().
// Create event, after jolt_start() has succeeded.
body = jolt_box_create_static(0, 0, 3, 1, 1, 1);
if (is_undefined(body)) {
var error = jolt_get_error();
show_debug_message(error.message);
}
// Cleanup event, while the world still exists.
if (!is_undefined(body)) body.destroy();A unit box is created with its centre at height 3. The example handles creation failure and releases the body during cleanup.