Errors and Diagnostics
Resource Ownership
Keep one clear owner for each resource. A visual instance may own a body, while a persistent controller owns the world. Resources referenced by a vehicle, constraint or helper must not be destroyed behind that object's owner.
| API | Contract |
|---|---|
| Managed world | Owns simulation lifetime; jolt_stop() tears down managed resources and runtime. |
| JoltShape / cache / bodies | Separate native references can share the same immutable geometry. |
| GameMaker instance / user_data | Remain caller-owned; assigning them to a body does not transfer their lifetime. |
| Raw explicit world | Caller must manage dependencies and avoid shutting down shared runtime too early. |
// Instance Cleanup event; physics resources are released explicitly.
if (!is_undefined(body)) {
body.destroy();
body = undefined;
}