Music behind a door
Updated
Party music muffled behind a closed door opens up when the door opens: a Low Pass filter on a Positional Audio, its cutoff changed by a Behavior script on door signals.
With your sound on, press Open door and Close door and listen to the music change. Drag to orbit the camera, scroll to zoom.
Music behind a door
#pragma lifecycle(startup)
let lowPass;
function startup() { lowPass = findEntity('Party Music').getComponent(AudioLowPassFilterComponent);
on('door/open', () => lowPass.setProps({ frequency: 20000 })); on('door/close', () => lowPass.setProps({ frequency: 600 }));}How it works
Section titled “How it works”The script is explained step by step in Music behind a door.
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.
MuffledPartyMusic.xrproj