Skip to content

Bone Physics

Physics chains give bones secondary motion. Each viewer’s client runs the simulation. A tail trails behind a walking bearer, swings out on a turn, and settles when the bearer stops. Gravity pulls toward the ground in every pose, so a sleeping or swimming bearer’s tail still hangs down. Poses and keyframe clips set the target shape, and physics adds motion on top of that shape. A drooped ear still swings, and a wagging tail still follows through.

"physics": {
"chains": [
{ "bones": ["tail_1", "tail_2", "tail_3"], "preset": "tail" }
]
}

bones is one chain, ordered from root to tip. Each bone must be a descendant of the bone before it in the geometry. A definition can have several chains, for example one for each tail or one for each ear.

Start with a preset. Add a knob only when the preset does not feel correct:

{ "bones": ["tail_1", "tail_2", "tail_3"], "preset": "tail", "drag": 2.5, "limit": 25 }
PresetUse for
tailMost tails: cat, dog, lizard.
tail_heavyThick, slow tails: drakes, crocodiles, big lizards.
tail_fluffyBushy tails that catch the air: foxes, squirrels.
ear_stiffEars that stand up and twitch.
ear_floppyEars that hang and flop forward and back.
braidHanging ropes of hair, and thin tails with a tuft.
hairLoose hair and manes.
beardBeards and other chin growth.
antennaSpringy feelers that wobble.
featherSingle stiff feathers and fins.

A pack can add its own presets as data/<namespace>/physics_preset/<id>.json. A preset file holds the same knobs a chain does. A bare preset id such as "tail" looks in the attachment’s own namespace first, then in townstead. So examplepack:tail replaces the built-in tail for every attachment in examplepack. To use a preset from a different namespace, write the full id, for example "examplepack:tail_whip".

KnobDefaultRangeNotes
frequency2.00.1 to 10How fast the chain returns to its pose, in swings per second. Higher is quicker and stiffer.
damping_ratio0.70.02 to 3How much the chain overshoots. Below 1 it swings past the pose and back. At 1 or more it settles without a swing.
gravity0.150 to 2How far each bone droops toward the ground. 0 is none. 1 is heavy.
inertia0.50 to 1How much of the bearer’s movement the chain feels. 1 is all of it. 0 is none, so the chain moves rigidly with the body.
drag1.00 to 20Air resistance. Higher streams the chain back further when the bearer moves, and lets wind push it more.
limit350 to 180The largest swing of each bone away from where its parent points, in degrees.
hingenonenone, pitch, sideKeeps each bone’s swing in one plane. pitch swings up and down. side swings left and right.
collideevery collidercollider namesThe rig colliders the chain rests against. See Colliders.
rest_pitch0degreesTilts the rest pose of every bone in the chain.
sway0degreesGentle idle motion. 0 turns it off.
sway_speed1Multiplies the speed of the idle motion.
scale_with_sizetrueMakes small bearers move quicker and large bearers move slower.
segmentsoff2 to 8Slices a single bone into a bending chain. See Auto-Segmentation.
axisautoauto, x, y, zThe axis that segments slices along.

gravity and limit apply to each bone. A three-bone tail with a limit of 30 can bend up to 90 degrees at its tip.

The six number knobs (frequency, damping_ratio, gravity, inertia, drag, limit) also accept a ramp from the root bone to the tip bone:

{ "bones": ["tail_1", "tail_2", "tail_3", "tail_4"], "preset": "tail", "frequency": { "root": 2.4, "tip": 1.6 } }

The bones between the root and the tip get values in between. A ramp with only tip or only root uses that one value along the full chain.

Tune one knob at a time, in this order:

  1. Set frequency for the speed. A large, heavy part moves slowly, so use a lower value.
  2. Set damping_ratio for the bounce. Use 0.4 to 0.6 for a springy part. Use 0.8 to 1.0 for a calm part.
  3. Set limit to keep the chain away from the body.
  4. Set drag for how much the chain trails while the bearer moves and how much wind moves it.
  5. Set gravity for how much the chain hangs.

Test each change on a live bearer with /townstead attachment adjust. See Live Tuning.

MoveShows
Walk, then stopdrag, inertia, and how the chain settles
Jump and landinertia and damping_ratio
Turn on the spotfrequency and limit
Stand in the raindrag and wind

A rig can list capsules on its bones. Chains rest against these capsules instead of swinging through the body. A humanoid body that lists no colliders uses the humanoid colliders: one around the body, one around each leg, and one around the head. This includes villagers, players, and rigs made from humanoid mob models such as the zombie or the skeleton. Other bodies, such as a spider or a custom geometry, have no colliders unless their rig lists them. To add colliders to your own rig, see Rigs.

A chain rests against every collider of its rig by default. To use only some colliders, name them:

{ "bones": ["tail_1", "tail_2", "tail_3"], "preset": "tail", "collide": ["right_leg", "left_leg"] }

To turn colliders off for a chain, use an empty list: "collide": [].

If a pose or clip puts a bone inside a collider, physics does not push that bone out. Townstead always keeps the authored pose.

All bearers in a level feel the same wind. The wind changes direction slowly and comes in gusts. It is stronger in rain and storms, slightly stronger in autumn and winter, and slightly weaker in summer. A bearer gets less wind with less sky light, so there is no wind indoors or underground. A chain with more drag moves more in the wind.

A bone in water moves much more slowly, and it floats up a little instead of hanging down.

Each player can set Attachment Physics in the Townstead client configuration:

SettingEffect
FullPhysics, colliders, wind, and water for bearers up to 48 blocks away.
LowPhysics, colliders, and water for bearers up to 16 blocks away. No wind.
OffNo physics. Attachments keep their pose.

Reduce Motion in the accessibility settings sets the maximum to Low.

/townstead attachment adjust <id> physics <chain|all> <knob> <value>

chain is the chain index, or all. knob is any knob name in snake case, for example damping_ratio. To set one end of a ramp, add .root or .tip, for example frequency.tip. Changes show on every bearer immediately and last until the next reload. To keep them, use /townstead attachment dump <id>. The dump writes the chain as its preset plus only the knobs that differ from the preset. See Tooling & Commands.

A tail made as one solid bone can still bend. Give the chain one bone and a segments count:

"chains": [
{ "bones": ["tail"], "segments": 4, "axis": "auto", "preset": "tail" }
]

When the model loads, the bone’s cubes are sliced into that many chained segments along the axis. auto uses the longest axis. The UVs are cut to match, so the sliced tail looks the same as the original at rest.

Physics files from before presets still load. Each old key converts to the new knobs:

Old keyBecomes
stiffnessfrequency
dampingNot used. The chain gets the preset’s damping_ratio, or the default.
max_angle, min_pitch, max_pitchlimit
gravity, droop_anglegravity
response, snapinertia
followNot used.

/townstead attachment doctor lists each old key it finds. To update a file, replace the old keys with a preset, then tune with the knobs.

  • Each mirrored anchor has its own simulation, so both ears of a pair swing in the same world direction.
  • A life-stage geometry swap starts the simulation again for the new model.
  • A teleport, or a bearer that is off screen for a moment, resets the chain to its pose. The chain does not snap across the distance.
  • Previews in screens (inventory, wardrobe, character editor) have their own simulation. A chain swings when you turn the preview.