AI Proximity
Updated
Detects when the active camera enters or leaves this box.
- Type
comp-ai-proximity- Script class
AIProximityComponent- Per entity
- One
- Version
- 1.0.0
Read about it in Dialog and captions: what it does, how to use it from a script, and examples.
Properties
Section titled “Properties”The props the runtime declares for this component, with their defaults and accepted ranges.
| Prop | Default | Range |
|---|---|---|
halfExtents |
||
halfExtents.x |
0. |
|
halfExtents.y |
0. |
|
halfExtents.z |
0. |
Events
Section titled “Events”Sent to the entity’s Signal Emitter as { entityId, eventType, data }. Compare eventType with the EventType constants.
AIProximity::enterAIProximity::exit
Live example
Section titled “Live example”Run it in the browser, read its scripts, and download it as an XR Creator project.
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.
From a script
Section titled “From a script”#pragma lifecycle(startup)
function startup() { const component = self.parent.getComponent(AIProximityComponent); if (component) log(component.props);}