Greet the player on approach
Updated
An AI Proximity box round the guide shows her dialog only while the camera is near, and a Behavior script hides the “walk up” hint on the proximity’s enter event.
Hold W to walk the camera inside the blue ring: the hint goes and the guide's dialog appears. Hold S to walk back out. The greeting itself is sent to the AI service, which this preview does not have, so the panel shows a short error instead of a reply.
Greet the player on approach
#pragma lifecycle(startup)
function startup() { const guide = findEntity('Guide'); const proximity = guide.getComponent(AIProximityComponent); const hint = findEntity('Talk Hint');
proximity.setProps({ halfExtents: { x: 3, y: 2, z: 3 }, enterPrompt: 'The visitor just walked up. Greet them in one sentence.', leavePrompt: '', });
hint.visible = !proximity.getSnapshot().inside;
on('guide:ai', (event) => { if (event.eventType === EventType.AIProximity.Enter) hint.visible = false; if (event.eventType === EventType.AIProximity.Exit) hint.visible = true; });}How it works
Section titled “How it works”The script is explained step by step in Greet the player on approach.
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.
GuideGreeting.xrproj