A pickup that bobs and pops
Updated
Two endless tweens bob and spin a pickup; on pickup/taken they stop, a third shrinks it away, and the pickup is destroyed.
Watch the gem bob and spin, then press Take to make it pop and vanish. Drag to orbit the camera, scroll to zoom.
A pickup that bobs and pops
#pragma lifecycle(startup)
async function startup() { const start = self.parent.position.y; Tween.to(self.parent.position, { y: start + 0.2 }, { ease: Ease.InOutSine, repeat: Infinity, yoyo: true }); Tween.to(self.parent.rotation, { y: M_TAU }, { duration: 3, ease: Ease.Linear, repeat: Infinity });
on('pickup/taken', async () => { Tween.stop(self.parent.position); Tween.stop(self.parent.rotation); await Tween.to(self.parent.scale, { x: 0, y: 0, z: 0 }, { duration: 0.3, ease: Ease.InBack }); destroy(self.parent); });}How it works
Section titled “How it works”The script is explained step by step in A pickup that bobs and pops.
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.
PickupPop.xrproj