A sorting puzzle
Updated
Two Snap Zones that take every swatch, and a script that counts on each change how many swatches sit in the zone their name matches.
Drag the warm swatches into the left frame and the cool ones into the right. Scroll to zoom.
A sorting puzzle
#pragma lifecycle(startup)
const TOTAL = 6;
function startup() { const warm = findEntity('Warm').getComponent(SnapZoneComponent); const cool = findEntity('Cool').getComponent(SnapZoneComponent);
const correct = (zone, prefix) => zone.contents.filter((item) => item.name.startsWith(prefix)).length;
on('sorting', (event) => { if (event.eventType !== EventType.SnapZone.Change) return; const right = correct(warm, 'Warm') + correct(cool, 'Cool'); log(`${right} of ${TOTAL} sorted`); if (right === TOTAL) emit('puzzle/solved'); });}How it works
Section titled “How it works”The script is explained step by step in A sorting puzzle.
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.
SortingPuzzle.xrproj