A lamp blinking with delay
Updated
A point light switched on and off every half second by a script that schedules itself with delay instead of setInterval.
Watch the lamp blink. Drag to orbit the camera, scroll to zoom.
A lamp blinking with delay
#pragma lifecycle(startup)
let lit = true;let light = null;let brightness = 0;
function blink() { lit = !lit; light.setProps({ intensity: lit ? brightness : 0 }); delay(blink, 500);}
function startup() { light = self.parent.getComponent(PointLightComponent); if (!light) { log('Put this Behavior under a point light.'); return; } brightness = light.props.intensity; delay(blink, 500);}How it works
Section titled “How it works”The script is explained step by step in A lamp blinking with delay.
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.
BlinkingLamp.xrproj