Drop marbles on a Mesh Collider
Updated
A big static ring has a Mesh Collider, which uses its exact triangles: marbles that land on the ring roll off it, and marbles over its hole fall straight through, which no box or convex shape would allow.
Watch the marbles over the hole drop through it and the others bounce off the ring. Drag to orbit the camera, scroll to zoom.
Drop marbles on a Mesh Collider
#pragma lifecycle(startup)
function wait(ms) { return new Promise((done) => delay(done, ms));}
async function startup() { const marbles = []; for (let i = 1; i <= 8; i++) { const marble = findEntity(`Marble ${i}`); marbles.push({ body: marble.getComponent(PhysicsRigidBodyComponent), home: marble.position.clone() }); } log('The ring collides with its exact triangles, hole included'); for (;;) { await wait(5000); const through = marbles.filter(({ body }) => Math.hypot(body.entity.position.x, body.entity.position.z) < 0.6).length; log(`${through} marbles fell through the hole`); for (const { body, home } of marbles) body.teleport(home); }}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.
MeshColliderRing.xrproj