Open a portal when a key is collected
Updated
A Travel Point into the vault stays closed until you press Pick up the key; then it opens with a gold ring, and walking into it lands you on the vault’s out portal, which reports your arrival.
Press Pick up the key, then walk forward with W into the gold ring to travel to the vault. Drag to look around.
Open a portal when a key is collected
#pragma lifecycle(startup)
function startup() { const portal = findEntity('Vault Portal In'); const gate = portal.getComponent(TravelPointComponent); gate.setEnabled(false); // closed until the key is found
on('key/collected', () => { gate.setEnabled(true); gate.setProps({ color: '#facc15' }); log('The vault portal is open'); });
on('vault-exit', (event) => { if (event.eventType === EventType.TravelPoint.Arrive) emit('music/vault'); });}How it works
Section titled “How it works”The script is explained step by step in Open a portal when a key is collected.
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.
VaultPortal.xrproj