Show an agent's speed
Updated
A wandering Steering Agent’s velocity is shown as a speed on a Text sign, updated only when the rounded value changes.
Watch the speed change as the agent wanders, speeds up and turns. Drag to orbit the camera, scroll to zoom.
Show an agent's speed
#pragma lifecycle(startup, update)
let agent;let label;let shown = '';
function startup() { agent = self.parent.getComponent(SteeringAgentComponent); label = findEntity('Speed Label').getComponent(TextComponent);}
function update() { const v = agent.velocity; const text = `${Math.hypot(v.x, v.z).toFixed(1)} m/s`; if (text === shown) return; shown = text; label.setProps({ text });}How it works
Section titled “How it works”The script is explained step by step in Show an agent’s speed.
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.
SpeedReadout.xrproj