A round minimap
Updated
Every frame a script redraws a round UI Drawing in the corner of the screen with a dot at the player’s position on a 40 m map.
Watch the red dot on the minimap follow the amber player around the yard. Drag to orbit the camera, scroll to zoom.
A round minimap
#pragma lifecycle(startup, update)
// Scene: a HUD panel with a UI Drawing named 'Minimap',// and an entity named 'Player' that moves around a 40 m square level.const SIZE = 160; // layout pxconst WORLD = 40; // metres shown across the maplet map;let player;
function startup() { map = findEntity('Minimap').getComponent(UIDrawingComponent); map.setProps({ width: SIZE, height: SIZE, borderRadius: SIZE / 2, background: '#0f172a' }); player = findEntity('Player');}
function drawMap(ctx) { map.clear(); const x = SIZE / 2 + (player.position.x / WORLD) * SIZE; const y = SIZE / 2 + (player.position.z / WORLD) * SIZE; ctx.fillStyle = '#f87171'; ctx.beginPath(); ctx.arc(x, y, 5, 0, M_TAU); ctx.fill();}
function update() { map.draw(drawMap);}How it works
Section titled “How it works”The script is explained step by step in A round minimap.
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.
RoundMinimap.xrproj