Capsule
Creates a capsule whose public default axis is Z.
x, y, and z are the centre of the full capsule, not its lower point. The shape combines a cylindrical middle with two hemispheres. Dynamic, Static, and Kinematic are supported.
Syntax#
jolt_capsule_create_dynamic(x, y, z, height, radius, options=undefined)
jolt_capsule_create_static(x, y, z, height, radius, options=undefined)
jolt_capsule_create_kinematic(x, y, z, height, radius, options=undefined)Arguments#
| Argument | Type | Description |
|---|---|---|
| x, y, z | Real | World-space centre of the full capsule. |
| height | Real | Total tip-to-tip Z height; must be > 2*radius. |
| radius | Real | Finite radius > 0 for the cylinder and hemispheres. |
| options | Struct | Shared options struct. |
Native CapsuleShape uses local Y. The wrapper rotates it +90° around X to public Z before applying body rotation.
Return and validation#
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. height <= 2*radius, non-positive radius, non-finite values, and invalid options are rejected. Debug draw respects tip-to-tip height.
Reusable JoltShape#
var shape = jolt_shape_capsule(height, radius, cache_key=undefined);
shape.create_dynamic(x, y, z, options);
shape.create_static(x, y, z, options);
shape.create_kinematic(x, y, z, options);Example#
var capsule = jolt_capsule_create_dynamic(3, 0, 5, 2.0, 0.45, {
rotation_euler:{x:0, y:0, z:0}
});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_capsule_create_dynamic | jolt_capsule_create_dynamic(x = 0, y = 0, z = 0, height = 2, radius = 0.5, options = undefined) | Factory for the named motion type, XYZ position defaults 0m plus options. total height >2*radius, radius>0 m, defaults 2/.5. Returns JoltBody/undefined; options failure cleans up the new body. Finite dimensions; set_ changes preserve identity. |
| jolt_capsule_create_kinematic | jolt_capsule_create_kinematic(x = 0, y = 0, z = 0, height = 2, radius = 0.5, options = undefined) | Factory for the named motion type, XYZ position defaults 0m plus options. total height >2*radius, radius>0 m, defaults 2/.5. Returns JoltBody/undefined; options failure cleans up the new body. Finite dimensions; set_ changes preserve identity. |
| jolt_capsule_create_static | jolt_capsule_create_static(x = 0, y = 0, z = 0, height = 2, radius = 0.5, options = undefined) | Factory for the named motion type, XYZ position defaults 0m plus options. total height >2*radius, radius>0 m, defaults 2/.5. Returns JoltBody/undefined; options failure cleans up the new body. Finite dimensions; set_ changes preserve identity. |