A lift on a Motion Path, called by a button
Updated
A kinematic lift on a two-point Motion Path: each press of Call lift reverses the points, rewinds and plays, so the lift rides up or down and carries the crate on it.
Press Call lift to send the lift up, and again to bring it down. Drag to orbit the camera, scroll to zoom.
A lift on a Motion Path, called by a button
#pragma lifecycle(startup)
function startup() { // The Lift has a kinematic Rigid Body and a Motion Path: // two points (bottom, top), repeat: 'once', autoStart: false. const lift = findEntity('Lift').getComponent(MotionPathControllerComponent); let atTop = false;
on('lift/call', () => { atTop = !atTop; if (atTop) { lift.setProps({ points: [[0, 0, 0], [0, 6, 0]] }); } else { lift.setProps({ points: [[0, 6, 0], [0, 0, 0]] }); } lift.setProgress(0); lift.play(); });}How it works
Section titled “How it works”The script is explained step by step in A lift on a Motion Path, called by a button.
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.
LiftCall.xrproj