Bowl at capsule pins
Updated
Six pins with Capsule Colliders, which fit tall rounded shapes exactly, stand on a lane; every few seconds the script rolls the amber ball into them, then teleports the pins back up.
Watch the ball knock the pins over and the pins stand up again for the next roll. Drag to orbit the camera, scroll to zoom.
Bowl at capsule pins
#pragma lifecycle(startup)
function wait(ms) { return new Promise((done) => delay(done, ms));}
const axis = new THREE.Vector3();
// How upright the pin stands: 1 straight up, 0 lying flat.function upright(pin) { return Math.abs(axis.set(0, 1, 0).applyQuaternion(pin.quaternion).y);}
async function startup() { const pins = []; for (let i = 1; i <= 6; i++) { const pin = findEntity(`Pin ${i}`); pins.push({ body: pin.getComponent(PhysicsRigidBodyComponent), home: pin.position.clone(), turn: pin.quaternion.clone() }); } const ballEntity = findEntity('Ball'); const ball = ballEntity.getComponent(PhysicsRigidBodyComponent); const ballHome = ballEntity.position.clone(); log('Six pins with Capsule Colliders: radius', pins[0].body.entity.getComponent(CapsuleColliderComponent).props.radius, 'm');
for (let round = 1; ; round++) { await wait(1500); ball.teleport(ballHome); ball.applyImpulse({ x: Random.range(-0.4, 0.4), y: 0, z: -9 }); await wait(4000); const down = pins.filter(({ body }) => upright(body.entity) < 0.9).length; log(`Roll ${round}: ${down} of 6 pins down`); for (const pin of pins) pin.body.teleport(pin.home, pin.turn); }}Open it in XR Creator
Section titled “Open it in XR Creator”Download the project file below, then import it in XR Hub with Projects › New › Import, as described in Projects and templates. It opens in XR Creator with the same scene you see running above, each script already attached to its Behavior entity. From there you can edit the scripts, adjust components and their props, preview your changes, and deploy the result as a world of your own.
CapsulePins.xrproj