Skip to content

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

Loading physics…
Orange: free to rotate (topples). Green: rotations locked (stays upright).

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"],
});