Skip to content

Dynamic bones

Updated

Dynamic bones give a model secondary motion: movement that is not authored but follows from other movement. When a fox runs, its tail lags behind, swings past and settles; when a character turns, its ponytail sways. The model moves, by a clip, a timeline, physics or a script, and its dynamic bones react on their own. Secondary motion makes characters feel alive at almost no authoring cost.

Component Type Motion
Dynamic Velocity Bone comp-dynamic-velocity-bone One bone softly follows its parent: hair, ears.
Dynamic Spring Bone comp-dynamic-spring-bone One bone springs after its parent, overshooting and settling: tails, jiggle.
Dynamic Skeleton comp-dynamic-skeleton The bones the model itself marks, a velocity scale for the whole model, and script access to every swinging bone.

All go on a model entity (glTF, FBX, Collada, OBJ, USDZ or a kit piece). Add one velocity or spring bone component per bone, as many as you need, and at most one Dynamic Skeleton.

  • Dynamic bones act on a model’s skeleton; Skeleton and morphs explains bones and bone names.
  • Dynamic bones solve last in the frame, after clips, timelines and scripts. See Animation.
  • An entity can hold several bone components. getComponents(DynamicSpringBoneComponent) lists them, and the base class DynamicBoneComponent finds both kinds: getComponents(DynamicBoneComponent).

Each dynamic bone chases where its tip would be at rest, and only rotates to aim at it: it is never re-parented or stretched.

  • Follow or spring. A velocity bone closes in on its rest smoothly, at its velocity. A spring bone behaves like a damped spring: with little damping it overshoots and oscillates; with a lot it creeps to rest without passing it.
  • Limited swing. A bone swings at most 75° from rest, so a model moved hard never folds through itself.
  • Frame-rate independent. The motion is the same at any frame rate.
  • Over clips and scripts. A clip or a script posing the bone this frame sets its rest, and the bone swings about it.

Both bone components share these props:

Prop Type Default Description
bone string '' The bone’s name, as loaded or as in the modelling tool. It must have a parent.
lockPosition { x?, y?, z? } of booleans all false Model axes along which the tip cannot move. Missing axes are unlocked.

A name that is not a bone logs a warning, and the component does nothing.

Prop Type Default Description
velocity number 0.1 How fast it follows its parent, from 0.01 to 10. Lower follows more slowly.
Prop Type Default Description
stiffness number 500 Its pull back to rest, from 10 to 100000. Higher is snappier.
damping number 17 Its friction, from 0 to 10000. Higher swings less.
mass number 1 Its weight, from 0.001 to 1000. Higher is heavier and slower.
Prop Type Default Description
mode 'marks' | 'explicit' 'marks' marks also swings the bones the model marks; explicit swings only the bones its velocity and spring bone components name.
velocityScale number 1 Scales the velocity of every velocity bone of the entity, from 0 to 10. Spring bones are not scaled.

In marks mode, the Dynamic Skeleton swings bones that the model marks with custom properties set in the modelling tool and exported with the model: wiggleVelocity makes a velocity bone, wiggleStiffness (with optional wiggleDamping) makes a spring bone, and wiggleLockX, wiggleLockY, wiggleLockZ lock axes. A component naming the same bone wins over the model’s marks.

A Dynamic Skeleton is not required: velocity and spring bones work alone. Add one for the model’s marks, velocityScale, or script access to the swinging bones.

lockPosition axes are the model’s own axes. They turn with the model and are the same for every bone.

  • lockPosition: { y: true } keeps the tip from moving along the model’s up axis: a model bobbing up and down never sets the bone swinging.
  • lockPosition: { x: true, z: true } leaves only Y: the bone reacts to up and down motion alone.

A lockPosition edit replaces the whole object; omitted members become false.

Member On What it does
reset() bone components, Dynamic Skeleton Snaps the bones it moves back to rest now and clears their motion, for example after a teleport.
bones() Dynamic Skeleton Every bone of the entity that swings, marked or named by a component. The same array on every call.
bone(name) Dynamic Skeleton The swinging bone name; undefined when it does not swing.
hasBones() Dynamic Skeleton Whether any bone of the entity swings.
velocityScale Dynamic Skeleton The scale it applies: its own while enabled, otherwise 1.

A pose you set on a bone from bones() or bone(name) becomes its rest: the bone swings about it.

  • Start from the defaults. velocity: 0.1 is soft and floppy; raise it toward 0.3 for a tighter follow. stiffness: 500, damping: 17, mass: 1 give a lively, bouncy spring.
  • Bounce versus settle. A spring stops oscillating at about damping = 2 × √(stiffness × mass), around 45 for the default stiffness and mass. Below that it overshoots; above it, it creeps back without passing rest.
  • Heavy or light. Raise mass for a slower, heavier swing; raise stiffness for a quicker, snappier one.
  • Chains. Give each bone of a tail or a strand its own component. Lower velocities toward the tip, or softer springs, read as a whip.
  • Unwanted bobbing. If walking makes ears or antennae flap, lock the axes they should ignore.

1. A balloon dog with spring ears and a wagging tail

Section titled “1. A balloon dog with spring ears and a wagging tail”

The bones are set up in the editor, with no code: the balloon dog model has a Dynamic Skeleton, a Dynamic Spring Bone on each ear bone (Bone2, Bone4, Bone8, Bone10, stiffness: 200, damping: 8) and a Dynamic Velocity Bone on each tail bone (Bone20 to Bone22, velocity falling from 0.2 to 0.1 toward the tip). An Animation Timeline on the dog has a Hop layer that moves it up and sideways. A Behavior under the dog only starts the hop:

PlayHop.jx
#pragma lifecycle(startup)
function startup() {
const timeline = self.parent.getComponent(AnimationTimelineComponent);
timeline.layer('Hop').play({ repeat: 'repeat' });
}
  • The timeline moves the whole dog; nothing animates the ears or the tail. Their swing is the dynamic bones answering the motion.
  • The ears are springs: they overshoot and bounce back each time the dog lands. The tail bones follow with velocity, softer toward the tip, so the tail trails behind like a whip.

A model without any marks gets spring bones from a script, then is swung from side to side so its top lags and whips behind. The stick also carries a Skeleton, so selecting it in XR Creator draws its three bones over the mesh.

SpringyStick.jx
#pragma lifecycle(startup, update)
const stick = self.parent;
let shaking = true;
let phase = 0;
function startup() {
// Softer toward the tip, so it whips.
['Bone.001', 'Bone.002'].forEach((bone, i) => {
stick.addComponent(new DynamicSpringBoneComponent({ bone, stiffness: 300 - i * 120, damping: 6 }));
});
log('Spring bones:', stick.getComponents(DynamicSpringBoneComponent).length);
}
function update(dt) {
if (Input.keyboard.isKeyReleased(Key.Space)) {
shaking = !shaking;
log(shaking ? 'Shaking' : 'Holding still');
}
if (!shaking) return;
phase += dt * 4; // only while shaking, so it resumes where it stopped
stick.setPosition(Math.sin(phase) * 0.5, 0, 0);
}
  • bone takes the name as in the modelling tool: Bone.001 loads as Bone001, and either works.
  • The top bone gets the lower stiffness, so it swings more than the one below it.
  • damping: 6 is low, so the stick wobbles for a while after Space stops the shaking.
  • setPosition moves the whole entity; the spring bones react to that motion on their own.
  • phase advances by dt only while shaking, so after a pause the swing carries on from where it stopped instead of jumping.

A script can give any loaded model secondary motion. This one adds a three-bone spring tail and two velocity ears to a fox.

FoxWiggle.jx
#pragma lifecycle(startup)
function startup() {
const fox = self.parent;
// A tail: softer toward the tip, so it whips.
const tail = ['Tail_01', 'Tail_02', 'Tail_03'];
tail.forEach((bone, i) => {
fox.addComponent(new DynamicSpringBoneComponent({
bone,
stiffness: 600 - i * 150,
damping: 15,
}));
});
// Ears that ignore the up-and-down bob of running.
for (const bone of ['Ear_L', 'Ear_R']) {
fox.addComponent(new DynamicVelocityBoneComponent({
bone,
velocity: 0.3,
lockPosition: { y: true },
}));
}
log('Dynamic bones:', fox.getComponents(DynamicBoneComponent).length);
}
  • Each tail bone gets its own spring component; stiffness drops from 600 to 300 toward the tip, which reads as a whip.
  • damping: 15 is below the critical value for these stiffnesses, so the tail overshoots and settles.
  • The ears use velocity bones with lockPosition: { y: true }, so running up and down does not set them flapping.
  • getComponents(DynamicBoneComponent) counts both kinds at once, because it is their shared base class.
  • The components bind as soon as the model is loaded, or once it loads, so the script does not need to wait.

Moving a model instantly makes its dynamic bones swing across the jump. reset() snaps them to rest.

TeleportReset.jx
#pragma lifecycle(startup)
function startup() {
on('fox/teleport', (spot) => {
self.parent.setPosition(spot.x, spot.y, spot.z);
for (const bone of self.parent.getComponents(DynamicBoneComponent)) bone.reset();
self.parent.getComponent(DynamicSkeletonComponent)?.reset();
});
}
  • Another script sends emit('fox/teleport', { x: 0, y: 0, z: -10 }); the listener receives that object as spot.
  • setPosition moves the entity at once.
  • Every bone component, and the Dynamic Skeleton if there is one (the ?. skips it otherwise), clears its motion, so the tail and ears start from rest at the new place.

Spring settings can change at runtime, but each change rebinds the model’s dynamic bones from rest. Change them on events, never every frame.

WetHair.jx
#pragma lifecycle(startup)
const DRY = { stiffness: 500, damping: 17, mass: 1 };
const WET = { stiffness: 300, damping: 30, mass: 3 };
let wet = false;
function setWet(value) {
if (value === wet) return; // an equal edit would change nothing anyway
wet = value;
for (const spring of self.parent.getComponents(DynamicSpringBoneComponent)) {
spring.setProps(wet ? WET : DRY);
}
log(wet ? 'Hair is wet' : 'Hair is dry');
}
function startup() {
on('weather/rain', () => setWet(true));
on('weather/sun', () => setWet(false));
}
  • getComponents(DynamicSpringBoneComponent) returns every spring bone on the entity.
  • setProps with three props at once makes one change, so the bones rebind once.
  • The heavier mass and higher damping make the hair swing slower and settle sooner, as wet hair does.
  • The early return skips work when the state does not change.

The Dynamic Skeleton’s velocityScale changes every velocity bone of the model together. This script lowers it while Shift is held and also reads the swinging bones.

SprintCalm.jx
#pragma lifecycle(startup, update)
const dynamic = self.parent.getComponent(DynamicSkeletonComponent);
let sprinting = false;
function startup() {
if (dynamic?.hasBones()) {
log('Swinging bones:', dynamic.bones().map((b) => b.name).join(', '));
}
}
function update() {
if (!dynamic) return;
const now = Input.keyboard.isKeyPressed(Key.ShiftLeft);
if (now === sprinting) return;
sprinting = now;
dynamic.setProps({ velocityScale: sprinting ? 3 : 1 });
}
  • A higher velocityScale makes velocity bones follow faster, so ears and hair stay tighter at speed. Spring bones are not affected.
  • The script calls setProps only when the key state changes; calling it every frame would rebind the bones from rest every frame.
  • bones() lists every swinging bone, whether marked in the model or named by a component.
  • Calling setProps every frame. An effective prop change rebinds every dynamic bone of the model from rest. Change props on events.
  • A bone name that does not exist. The component logs a warning and does nothing. Check names with a Skeleton’s bones().
  • A root bone. The bone must have a parent; the model’s root bone cannot swing.
  • Forgetting reset() after a teleport. The bones swing wildly across the jump.
  • Expecting motion in the editor. Dynamic bones move in the editor only while their entity is selected; test in Play.
  • Hidden models. A hidden or disabled entity solves nothing; its bones start again from rest when it shows.