Entering a cave
Updated
A sound inside an Audio Zone gains a long Reverb as the listener walks in: the zone’s enter and exit events tween the filter’s wet mix up and down.
With your sound on, hold W for about a second to walk the camera into the cave: the drum beat inside sounds, and the cave's reverb swells in. Hold S to walk out. Sounds inside a zone are silent from outside it. The beat is a short loop generated for this example.
Entering a cave
#pragma lifecycle(startup)
let reverb;let mix = 0;let fade;
function setWet(target) { if (fade) fade.stop(); fade = Tween.value(mix, target, (value) => { mix = value; reverb.setProps({ wet: value }); }, { duration: 1.5 });}
function startup() { reverb = findEntity('Footsteps').getComponent(AudioReverbFilterComponent);
on('cave', (event) => { if (event.eventType === EventType.AudioZone.Enter) setWet(0.6); if (event.eventType === EventType.AudioZone.Exit) setWet(0); });}How it works
Section titled “How it works”The script is explained step by step in Entering a cave.
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.
CaveReverb.xrproj