Resources and Assets

jolt_asset_create_body

Creates a managed compound rigid body from validated asset data.

Call jolt_start() successfully first. The function validates the data again, creates one body with a compound shape, and releases its temporary builder.

Syntax#

Syntax
jolt_asset_create_body(data, motion, [options]);
ArgumentTypeDescription
dataStructData returned by jolt_asset_load(). Validated again on creation.
motionRealJOLT_MOTION_STATIC / JOLT_MOTION_DYNAMIC / JOLT_MOTION_KINEMATIC
optionsStruct | undefinedOPTIONAL. Defaults to undefined. options.position is {x,y,z}, default {x:0,y:0,z:0}; omitted rotation is identity. For other high-level options see Compound Shapes and Body Properties.

Returns#

JoltBody | undefined

Success returns a JoltBody owning the finalized compound shape. Failure returns undefined; read jolt_get_error() immediately. An unsuccessful creation releases its partially built resources.

Lifetime#

Each call creates a separate body. The caller owns body.destroy(), or world teardown through jolt_stop(). The body owns its created geometry independently of the input JSON struct.

Example#

Add your exported asset to Included Files as props/crate.jolt.json. The example assumes that file exists; body creation also requires a running world.

GML
// The default world has already been started successfully.
var asset = jolt_asset_load("props/crate.jolt.json");
if (!is_undefined(asset)) {
    var body = jolt_asset_create_body(asset, JOLT_MOTION_DYNAMIC, {position:{x:0,y:0,z:3}});
    if (is_undefined(body)) {
        var error = jolt_get_error();
        show_debug_message(error.message);
    }
    else {
        // Keep body while the object is in use; release it when finished.
        body.destroy();
    }
}
else {
    var error = jolt_get_error();
    show_debug_message(error.message);
}

The example creates a dynamic body at height 3 and demonstrates its release. In a game, move destroy to the point where the body is no longer needed.

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_asset_create_bodyjolt_asset_create_body(data, motion, options = undefined)Asset + motion + optional options, position options.position {x, y, z} defaults 0. Returns JoltBody or undefined; transactionally builds collisions, not every asset helper. Old 5/6-argument overload remains compatible.