A thruster you hold
Updated
While Space is held, a lasting upward force lifts a drone; releasing Space removes it with resetForces, and gravity brings the drone back down.
Click the scene, then hold Space to lift the drone and let go to drop it. Drag to orbit the camera, scroll to zoom.
A thruster you hold
#pragma lifecycle(startup, update)
const THRUST = { x: 0, y: 30, z: 0 }; // a steady upward push
let body;let firing = false;
// On a dynamic drone with a Rigid Body and a collider.function startup() { body = self.parent.getComponent(PhysicsRigidBodyComponent);}
function update() { const held = Input.keyboard.isKeyPressed(Key.Space); if (held === firing) return;
firing = held; if (firing) { body.addForce(THRUST); } else { body.resetForces(); }}How it works
Section titled “How it works”The script is explained step by step in A thruster you hold.
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.
HoverThruster.xrproj