Physics drop
Updated
Dynamic rigid bodies with box and sphere colliders fall onto a floor that has only a collider, so it is fixed. Clicking a body gives it an upward impulse.
Click a box or a ball to throw it up. Drag to orbit the camera, scroll to zoom.
Physics drop
#pragma lifecycle(startup)
function startup() { on('body/clicked', (event) => { if (event.eventType !== EventType.Selectable.Select) return; const entity = findEntity(event.entityId); if (!entity) return; // Select fires only on becoming selected: release it so every click counts. entity.getComponent(SelectableComponent).setSelected(false); const body = entity.getComponent(PhysicsRigidBodyComponent); if (!body) return; body.applyImpulse({ x: (Math.random() - 0.5) * 2, y: 6, z: (Math.random() - 0.5) * 2 }); log(`Kicked ${entity.name}`); });}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.
PhysicsDrop.xrprojWhat it uses
Section titled “What it uses”- Physics Rigid Body
- Box Collider
- Sphere Collider
- Selectable
- Signal Emitter
- Camera Perspective
- Main Camera
- Orbit Controller