A low-gravity zone and sleep reporting
Updated
Bodies that enter a sensor zone get a gravity scale of 0.15 and float down gently; leaving it restores normal gravity. A second listener logs when each crate settles or moves again.
Watch the crates over the blue zone drift down while the other one drops. Grab a crate and lift it into the zone again. Drag elsewhere to orbit the camera.
A low-gravity zone and sleep reporting
#pragma lifecycle(startup)
const FLOATY = 0.15;
// The Zone is a group with a sensor Box Collider and a Signal Emitter with the signal 'zone'.// Each crate has a Rigid Body and a Signal Emitter with the signal 'crate'.function startup() { on('zone', (event) => { const body = findEntity(event.data.otherEntityId || '')?.getComponent(PhysicsRigidBodyComponent); if (!body) return; if (event.eventType === EventType.PhysicsCollider.IntersectionEnter) { body.setGravityScale(FLOATY); body.wakeUp(); } if (event.eventType === EventType.PhysicsCollider.IntersectionExit) { body.setGravityScale(1); } });
on('crate', (event) => { const name = findEntity(event.entityId)?.name; if (event.eventType === EventType.PhysicsRigidBody.Sleep) log(name, 'settled'); if (event.eventType === EventType.PhysicsRigidBody.Wake) log(name, 'moving again'); });}How it works
Section titled “How it works”The script is explained step by step in A low-gravity zone and sleep reporting.
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.
LowGravityZone.xrproj