Log inGet started
World

Pocket Putt Islands

README.md

Conveyor

Pairs an animatedMaterials belt material with a physically moving surface. Put it on an entity that has a BoxCollider (or another collider with surfaceVelocity) and wears beltRubber, beltSlats, treadmill or treadmillNeon: in edit mode and in play, it states the collider's surfaceVelocity as (beltSpeed, 0, 0) in the collider's own frame, the frame the belt's stripes travel in, so a crate resting on it moves exactly with the stripes. The speed is the object's live beltSpeed (Live.set(belt, "beltSpeed", 1.2), shared with every player), else the material's default. It writes the collider only when the speed changes. Field: driveCollider.

On an engine whose colliders have no surfaceVelocity field (the web build has shipped without it), the write is refused. The Conveyor then says so once in the log and carries what rests on the belt itself: the belt's collider is made frictionless while it carries (its own friction comes back when the component is removed), and at every physics step (once a frame where the engine has no Physics.onBeforeStep) each dynamic body whose middle (its bounds' centre, so a mesh pivoted at its base counts) stands over the belt is handed the belt's speed along it, plus a pull that closes any distance it has fallen behind on the shared game clock, so it keeps pace with the stripes. Bodies are found by an overlap query and by the belt's contacts; the belt's box comes from its oriented bounds, else its collider's half, else its scale. A body put back at the start of the belt starts afresh.

  • conveyor:_mode(): "surface" (the collider's surfaceVelocity), "carry" (the fallback) or "unknown" before the first write.
  • conveyor:_carryStats(): what carrying found: { mode, hook ("step", "frame" or "none"), steps, candidates, riders, bounds, lastError, speed }. In a browser console: entity.find("belt").component.get("Conveyor"):_carryStats().
  • conveyor:_currentSpeed(): the speed last given to the collider, m/s (nil in carry mode).
  • conveyor:_forceCarry(perFrame?): for tests, behave as on an engine without surfaceVelocity (and, with perFrame, without a physics step hook).