Locked rotations
A character capsule should slide and fall, but never tip over. You get that by restricting the body’s degrees of freedom to translation only. Both capsules below take the same off-center shove: the orange one rotates freely and topples, the green one has its rotations locked and just slides.
Drag to orbit
How it works
Section titled “How it works”The fluent builder has a lockRotations() shortcut:
const character = world.createBody( Body.dynamic() .shape(Shape.capsule({ halfHeight: 0.5, radius: 0.35 })) .translation(0, 0.85, 0) .layer("moving") .lockRotations(), // translation only — the capsule can't tip);lockRotations() is shorthand for allowing just the three translation axes. You can pick any subset explicitly:
world.createBody({ type: "dynamic", shape: Shape.capsule({ halfHeight: 0.5, radius: 0.35 }), allowedDofs: ["translation-x", "translation-y", "translation-z"],});Related
Section titled “Related”- Bodies & motion — the full
allowedDofslist. - jolt-ts-character-controller — a ready-made imperative character (and vehicle) controller built on jolt-ts, if you want more than an upright capsule.