Set off a shock wave where something explodes
Updated
Click a barrel and it disappears in a shock wave that ripples across the screen from where it stood: a Shock Wave effect on the camera, played by a Behavior script from Selectable clicks.
Click the barrels one by one. Reload to bring them back. Drag to orbit the camera, scroll to zoom.
Set off a shock wave where something explodes
#pragma lifecycle(startup)
const where = new THREE.Vector3();
function startup() { const wave = findEntity('Main Camera').getComponent(ShockWaveEffectComponent); wave.setProps({ speed: 2.5, maxRadius: 0.8, amplitude: 0.08 });
on('barrel/click', (event) => { if (event.eventType !== EventType.Selectable.Select) return; findEntity(event.entityId)?.getComponent(SelectableComponent)?.setSelected(false); // so the next click selects it again const barrel = findEntity(event.entityId); if (!barrel) return;
barrel.getWorldPosition(where); wave.play(where); destroy(barrel); });}How it works
Section titled “How it works”The script is explained step by step in Set off a shock wave where something explodes.
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.
BarrelShockWave.xrproj