Pop when clicked
Updated
A box that grows and settles back with a bounce when clicked: two awaited Tweens on its scale, started from a Selectable event.
Click the box. Drag to orbit the camera, scroll to zoom.
Pop when clicked
#pragma lifecycle(startup)
let box = null;let popping = false;
async function pop() { popping = true; await Tween.to(box.scale, { x: 1.4, y: 1.4, z: 1.4 }, { duration: 0.15, ease: Ease.OutQuad }); await Tween.to(box.scale, { x: 1, y: 1, z: 1 }, { duration: 0.4, ease: Ease.OutBack }); popping = false;}
function onBoxEvent(event) { if (event.eventType !== EventType.Selectable.Select) return; box.getComponent(SelectableComponent).setSelected(false); if (!popping) pop();}
function startup() { box = self.parent; on('box/clicked', onBoxEvent);}How it works
Section titled “How it works”The script is explained step by step in Pop when clicked.
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.
PopOnClick.xrproj