A bodyguard that keeps between
Updated
An amber bodyguard with a Steering Interpose keeps itself between a wandering VIP and the threat that seeks it, and a label shows how close it is to the line between them.
Watch the amber bodyguard slide into place between the violet VIP and the blue threat, and follow them as they move. Drag to orbit the camera, scroll to zoom.
A bodyguard that keeps between
#pragma lifecycle(startup, update)
let vip;let threat;let guard;let label;let shown = '';const mid = new THREE.Vector3();
function startup() { vip = findEntity('Violet VIP'); threat = findEntity('Blue Threat'); guard = findEntity('Bodyguard'); label = findEntity('Cover').getComponent(UILabelComponent); log('interposing between', guard.getComponent(SteeringInterposeComponent).props.targetA, 'and', guard.getComponent(SteeringInterposeComponent).props.targetB);}
function update() { // Interpose aims for the midpoint of its two targets. mid.addVectors(vip.position, threat.position).multiplyScalar(0.5); const off = Math.hypot(guard.position.x - mid.x, guard.position.z - mid.z); const text = off < 0.6 ? 'Covering the VIP' : `Moving in: ${off.toFixed(1)} m from the line`; if (text === shown) return; shown = text; label.setProps({ text, color: off < 0.6 ? '#34d399' : '#fbbf24' });}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.
BodyguardInterpose.xrproj