Physics · interface
RagdollOptions
Explained in Your first game, Rigid bodies.
interface RagdollOptionsimport type { RagdollOptions } from '@driftengine/physics';Properties
| Name | Type | Description |
|---|---|---|
radiusRatiooptional | number | Capsule radius, as a fraction of the bone's length. |
minRadiusoptional | number | A floor under the radius, so a short bone is not a needle. |
densityoptional | number | |
swingCosoptional | number | ArrayLike<number> | Cosine of the swing cone allowed: one number for every joint, or one per joint.MoreIt was one number for a whole body until 2026-08-28, and a body is not one joint. A knee is a hinge with no twist; a shoulder is nearly a ball. Given one pair, a consumer chooses which of the two is wrong — and the one who reported this chose loose, a 78° cone and 74° of twist at every joint, with a comment saying tight limits look like a wooden puppet. What it produced was reported from play as a scrambled ball of things, limbs torso head mixed together: at 78° nothing stops a knee or an elbow folding a limb through the torso, so a body that lands rolls itself into a knot. An array is indexed by the joint, exactly as What this does not buy is a real hinge. A narrow cone with no twist is a near hinge: it still bends a little in every direction, because a cone is a cone. A knee that cannot bend sideways at all needs a revolute joint and an axis, and the axis is rig data this builder is never given — a parent array and a set of world matrices do not say which way a knee folds. What would change it is a consumer measuring that sideways bend as the problem, and the answer then is a joint type per bone with the axis supplied, not a wider cone. A value here is compared every tick, so compute it the way the block below computes its
defaults. |
twistSinoptional | number | ArrayLike<number> | Sine of the half-angle of twist allowed: one number for every joint, or one per joint. |
minLengthoptional | number | Bones shorter than this get no body, which is how a rig's leaf tips are skipped. |
layeroptional | number | |
maskoptional | number | |
selfCollisionoptional | boolean | Whether the doll's own bones collide with each other. Default true.MoreBones that share an end are excluded either way, and that is not a setting. Two capsules jointed end to end overlap near the joint by construction, because that is what having a radius means, so every parent and child in a doll and every pair of siblings starts interpenetrating. Left to resolve, that contact fights the joint holding them together: a consumer measured it holding settled joints 14.2 cm open, turning a body at 3.0 rad/s while it lay still, and propping it 28 cm off the road on its own thighs.
|