Joints
Updated
A joint links rigid bodies so they move together under rules: welded into one piece, turning on a hinge, sliding on a rail, swinging on a ball and socket, tied by a rope or pulled by a spring. Joints are how you build doors, wheels, pendulums, chains, drawers, wobbly bridges and chandeliers that fall when their rope is cut. This page explains how a joint chooses the bodies it links, the six joint components and their props, and how a script changes or breaks them.
Before you start
Section titled “Before you start”- Every body a joint links needs a Rigid Body and a collider.
- You know the difference between dynamic, kinematic and fixed bodies. A joint usually hangs dynamic bodies from a fixed one.
- Joints are built with the physics world, in play only.
How a joint links bodies
Section titled “How a joint links bodies”A joint is a component on a group entity. It links the rigid bodies inside that group:
- Members. Every entity in the group’s subtree that has a live rigid body is a member, in child order. The group itself is the first member when it has a body. Entities without a Rigid Body are skipped.
- Anchor. The first member is the anchor.
- Star. Most joints link every other member back to the anchor.
- Chain. Rope and Spring joints link each member to the previous one by default, making a chain.
- Not enough members. A joint with fewer than two members links nothing.
- Frames. A joint measures where its bodies are the first time it binds, and keeps those measurements when it is rebuilt, so a slack rope stays slack.
- Self-collision. Linked bodies do not collide with each other unless
selfCollideis on.
Pivots, anchors and axes are given in the group’s local space.
Build a pendulum
Section titled “Build a pendulum”- Add a Group named
Pendulumwhere the pivot should be. Give it a Rigid Body with typefixed: it is the anchor. - Under it, add a Primitive Mesh sphere two metres below. Give it a Rigid Body (type
dynamic) and a Sphere Collider. - On the
Pendulumgroup, add a Spherical Joint and leave itspivotat0, 0, 0, the group’s origin. - Enter play and give the sphere a push, for example with the script in Push the pendulum. It swings about the pivot.
The joint components
Section titled “The joint components”| Component | Type | What it does |
|---|---|---|
| Fixed Joint | comp- |
Welds the bodies together, keeping their poses relative to the anchor: a compound assembly that can still break apart when you disable it. |
| Revolute Joint | comp- |
A hinge: bodies turn about one shared axis through a pivot. Wheels, fans, doors. |
| Prismatic Joint | comp- |
A slider: bodies move along one axis, with every rotation locked. Pistons, drawers, elevators. |
| Spherical Joint | comp- |
A ball and socket: bodies are pinned at a pivot and turn freely about it. Pendulums, ragdoll shoulders. |
| Rope Joint | comp- |
A maximum distance between bodies, with no force while slack. Ropes, chains, leashes. |
| Spring Joint | comp- |
A soft link that pulls the bodies toward a rest length, damped to settle. Suspensions, bouncy bridges. |
Fixed Joint
Section titled “Fixed Joint”| Prop | Type | Default | Description |
|---|---|---|---|
selfCollide |
boolean | false |
Let the welded bodies still collide with each other. |
Revolute Joint
Section titled “Revolute Joint”| Prop | Type | Default | Description |
|---|---|---|---|
pivot |
{ x, y, z } |
0, 0, 0 |
The hinge pivot, in the group’s local space. |
axis |
{ x, y, z } |
0, 1, 0 |
The hinge axis, a non-zero direction in the group’s local space. |
selfCollide |
boolean | false |
Let the linked bodies collide with each other. |
The axis is expressed in the anchor’s frame. Give the linked bodies the anchor’s orientation when they bind, as you usually would for hinges.
Prismatic Joint
Section titled “Prismatic Joint”| Prop | Type | Default | Description |
|---|---|---|---|
anchor |
{ x, y, z } |
0, 0, 0 |
The slider anchor, in the group’s local space. The bodies stay aligned through it. |
axis |
{ x, y, z } |
0, 1, 0 |
The slide axis, a non-zero direction in the group’s local space. |
selfCollide |
boolean | false |
Let the linked bodies collide with each other. |
As with the Revolute Joint, give the linked bodies the anchor’s orientation when they bind.
A fairground high striker: the puck rides a Prismatic Joint that lets it slide only along the pole. Every few seconds the script strikes it upward with a random impulse and logs how high it went; a hard hit rings the bell.
Watch the puck shoot up the pole and slide back down, staying on its axis whatever the impulse. Drag to orbit the camera, scroll to zoom.
Spherical Joint
Section titled “Spherical Joint”| Prop | Type | Default | Description |
|---|---|---|---|
pivot |
{ x, y, z } |
0, 0, 0 |
The ball-and-socket pivot, in the group’s local space. |
selfCollide |
boolean | false |
Let the linked bodies collide with each other. |
Rope and Spring
Section titled “Rope and Spring”Rope and Spring are link joints. They connect bodies centre to centre and share a topology prop:
| Prop | Type | Default | Description |
|---|---|---|---|
topology |
'chain' | 'star' |
'chain' |
chain links each body to the next in child order: anchor, link, link, weight. star links every body back to the anchor, tethering a cluster to one point. |
selfCollide |
boolean | false |
Let the linked bodies collide with each other. |
The Rope Joint adds:
| Prop | Type | Default | Description |
|---|---|---|---|
length |
number | spacing at first bind | The maximum distance between linked bodies, centre to centre. Left out, it is their distance when the joint first links them: they swing freely but never pull further apart than they started. |
The Spring Joint adds:
| Prop | Type | Default | Description |
|---|---|---|---|
restLength |
number | spacing at first bind | The separation the spring pulls toward, centre to centre. Left out, it is their distance when the joint first links them. |
stiffness |
number | 100 |
Restoring force per metre of stretch or compression. Higher is stiffer. |
damping |
number | 10 |
Force opposing the rate of length change, which bleeds off oscillation. Higher settles faster. |
The default spring constants suit bodies of about one kilogram.
Scripting
Section titled “Scripting”A joint is data. A script changes it like any component:
| Action | Call | Effect |
|---|---|---|
| Change a joint | joint. |
The joints are rebuilt with the new props. |
| Break a joint | joint. |
The bodies are unlinked and move freely. |
| Restore it | joint. |
The bodies are linked again. |
| Add a joint | group. |
Links the group’s bodies from where they are now. |
Joints send no events. To know when a linked body is hit, listen to the member bodies’ collision events.
Examples
Section titled “Examples”1. Cut the rope
Section titled “1. Cut the rope”A chandelier hangs from the ceiling on a Rope Joint. When a cut signal arrives, it falls.
#pragma lifecycle(startup)
function startup() { const rope = findEntity('Chandelier').getComponent(PhysicsRopeJointComponent); on('cut', () => { rope.setEnabled(false); log('The rope snaps'); });}A chandelier swings from a fixed hook on a Rope Joint; pressing the button raises cut and the script disables the joint, so the chandelier falls.
Press Cut the rope. Drag to orbit the camera, scroll to zoom.
getComponent(PhysicsRopeJointComponent)finds the joint on the group.setEnabled(false)unlinks the bodies. The anchor is fixed, so it stays; the chandelier, dynamic, falls with gravity.- Any script or interaction can emit
cut, for example a button or a sensor the player walks through.
2. Push the pendulum
Section titled “2. Push the pendulum”The pendulum from Build a pendulum gets a sideways kick each time the player presses P.
#pragma lifecycle(startup, update)
let bob;
function startup() { bob = findEntity('Bob').getComponent(PhysicsRigidBodyComponent);}
function update() { if (Input.keyboard.isKeyReleased(Key.P)) { bob.applyImpulse({ x: 2, y: 0, z: 0 }); }}A pendulum hangs from a fixed pivot on a Spherical Joint, a ball and socket; each press of P gives the bob a sideways impulse and it swings, free to turn in any direction about the pivot.
Click the view, then press P to push the bob; press it again mid-swing to add to the swing. Drag to orbit the camera, scroll to zoom.
- The joint keeps the bob at the same distance from the pivot, so a sideways impulse turns into a swing.
- Gravity brings it back, and the swing continues until the body’s damping, if any, slows it.
- You push the member body, not the joint. Joints have no forces of their own.
3. Stiffen a wobbly bridge
Section titled “3. Stiffen a wobbly bridge”A rope bridge is a chain of planks on a Spring Joint. Pulling a lever makes it rigid enough to cross.
#pragma lifecycle(startup)
const WOBBLY = { stiffness: 100, damping: 10 };const SOLID = { stiffness: 5000, damping: 400 };
let spring;let solid = false;
function startup() { spring = findEntity('Bridge').getComponent(PhysicsSpringJointComponent); on('lever/pulled', () => { solid = !solid; spring.setProps(solid ? SOLID : WOBBLY); log(solid ? 'The bridge holds firm' : 'The bridge sways'); });}A bridge of planks linked in a chain by a Spring Joint, held at both ends: it sags and sways under a ball, and Pull the lever stiffens the springs so it holds firm, with the same rest lengths.
Watch the bridge sag under the ball, then press Pull the lever to make it firm, and again to let it sway. Drag to orbit the camera, scroll to zoom.
- With
topology: 'chain', each plank is linked to the one before it, from the anchor out. setPropschangesstiffnessanddamping; the joints are rebuilt with them and keep their first-measured rest length, so the bridge does not jump.- High stiffness pulls planks back hard; high damping stops them bouncing.
4. A door that slams in the wind
Section titled “4. A door that slams in the wind”A door hangs on a Revolute Joint. Each gust turns it with a torque impulse: a shut door blows open, an open one slams shut against its stop.
#pragma lifecycle(startup)
const OPEN_PUSH = 1.35;const SLAM_PUSH = 6;
function startup() { const panel = findEntity('Door Panel'); const door = panel.getComponent(PhysicsRigidBodyComponent); on('weather/gust', (event) => { if (event.eventType !== EventType.UIButton.Press) return; // The hinge angle in degrees: 0 when shut, negative when open. const angle = (2 * Math.atan2(panel.quaternion.y, panel.quaternion.w) * 180) / Math.PI; const shut = angle > -20; door.wakeUp(); door.applyTorqueImpulse({ x: 0, y: shut ? -OPEN_PUSH : SLAM_PUSH, z: 0 }); log(shut ? 'The gust blows the door open' : 'The gust slams the door shut'); });}A door panel hangs on a Revolute Joint with a vertical hinge axis. Each press of Wind gust turns it with a torque impulse about the hinge: a shut door blows open, an open one slams shut against its stop.
Press Wind gust to blow the door open, then press it again to slam it shut. Drag to orbit the camera, scroll to zoom.
- The Revolute Joint lets the panel turn only about the vertical hinge axis.
applyTorqueImpulseabout Y turns it around that hinge. A torque about another axis would be resisted by the joint.- The panel’s angular damping slows each swing to a stop. Without it, one push would keep the door spinning forever.
- The Door Stop’s collider is what the door slams against. The Revolute Joint itself has no limits, so the stop sets where the door closes. Continuous collision on the panel keeps a hard slam from passing through the thin stop.
- The hinge angle, read from the panel’s rotation about Y, decides which way the gust blows, so pressing twice quickly never slams a door that is barely open.
wakeUpmakes sure a door that has come to rest reacts at once.- The button’s Signal Emitter sends its press on
weather/gust; the script checksEventType.UIButton.Press.
5. Break a weld on impact
Section titled “5. Break a weld on impact”A statue is built from parts welded with a Fixed Joint. A hard hit breaks it apart.
#pragma lifecycle(startup, update)
const BREAK_SPEED = 6;
let weld;let ball;let ballSpeed = 0; // last frame's speed, before a hit slows itlet broken = false;
function startup() { weld = findEntity('Statue').getComponent(PhysicsFixedJointComponent); ball = findEntity('Wrecking Ball');
on('statue', (event) => { if (broken || event.eventType !== EventType.PhysicsCollider.CollisionEnter) return; if (event.data.otherEntityId !== ball.entityId || ballSpeed < BREAK_SPEED) return; broken = true; weld.setEnabled(false); log(`Hit at ${ballSpeed.toFixed(1)} m/s: the weld breaks`); emit('statue/broken'); });}
function update() { const v = ball.getComponent(PhysicsRigidBodyComponent).linearVelocity(); ballSpeed = Math.hypot(v.x, v.y, v.z);}A statue of three parts welded by a Fixed Joint stands as one object until a falling wrecking ball hits it faster than 6 m/s: the script then disables the joint and the parts fall apart.
Watch the ball drop onto the statue and break the weld. Press Relaunch to see it again. Drag to orbit the camera, scroll to zoom.
- While the Fixed Joint is on, the parts move as one welded object.
- Every part reports its contacts on the same signal, so a hit anywhere on the statue counts.
- A contact event arrives after the physics step has already handled the hit, when the ball has slowed down.
updatekeeps the ball’s speed from the frame before, which is the speed it struck at. - Above
BREAK_SPEED,setEnabled(false)removes the weld: each part becomes a separate falling body. brokenmakes sure it breaks once.
Common mistakes
Section titled “Common mistakes”- Putting the joint on a mesh. Joint components are offered on groups only, and link the bodies inside the group.
- Members without a Rigid Body. Entities without one are skipped. Every linked part needs its own body.
- A dynamic anchor when you wanted a fixed point. The first member is the anchor. If it is dynamic, the whole assembly falls together. Make it fixed to hang things from it.
- Pivots in world coordinates. Pivots, anchors and axes are in the group’s local space.
- Misaligned hinge bodies. For Revolute and Prismatic joints, give the linked bodies the anchor’s orientation before play starts.
- Waiting for joint events. Joints send none; listen to the member bodies.
- Toggling bodies every frame. Each body change rebuilds every joint in the scene.