Log inGet started
Package

skyfallKit.package

Newest version

README.md

skyfallKit

Things that fall, drift, rise or fly across a play area in waves, for arcade games: falling stars to catch, fruit thrown up to slice, balloons and bubbles rising to pop, meteors to dodge, leaves to grab. Multiplayer-correct and cheap: one authority decides what spawns, and every screen computes the motion itself, so it is smooth everywhere without streaming a single transform.

Version 1.0.4 (Skyfall.VERSION). This README, package.yaml and Skyfall.VERSION move together.

What you get

  • 8 motions (per object): drop (straight down, gently accelerating), zigzag, swirl (spirals down through the depth), float (wobbly leaf drift), arc (thrown up from below, then falls, like fruit-slicing games), bounce (three bounces on the floor, then through it), rise (bubbles, balloons), dart (fast diagonal streak).
  • 8 wave patterns: rain (random across the width), line (a row), vee, burst (from one point, fanning out), spiral, sides (in from the left and right edges), lanes (fixed columns), fountain (thrown up from below).
  • 5 entry effects: popIn, fadeIn, streak, sparkle, none; 4 warning markers where an object will enter: ring, arrow, glow, none.
  • 5 placeholder looks: cartoon (bright, outlined), minimal (matte single shapes), neon (glowing), pixel (blocky), pastel (soft). Ten built-in shapes: orb, star, gem, bubble, balloon, rock, fruit, bomb, drop, leaf.
  • 5 difficulty curves over a round: linear, easeIn, steps, waves (breather moments), flat — spawnerKit's curves (~spawnerKit.curves) read over the round.
  • Events on every peer: spawned, escaped (left the play area, e.g. hit the ground: lose a life), removed (caught, cleared, or despawned by something else).
  • A SkyfallDirector component for a no-code shower, and a gallery demo showing every motion side by side.

Install

Search ZeroMind for skyfallKit (or "things falling from the sky in waves") and install skyfallKit.package; once published, install it by its guid with zeromind_install. It brings spawnerKit's curves module with it. Then:

local Skyfall = require("skyfallKit.skyfall")

Quick start (code)

local Skyfall = require("skyfallKit.skyfall")

-- 1. Kinds: call on EVERY peer (module scope or the world entrypoint), never only on the host.
Skyfall.defineKind("star",  { shape = "star",  motion = "float", speed = 2.0, radius = 0.6, data = { points = 10 } })
Skyfall.defineKind("gloom", { shape = "bomb",  motion = "drop",  speed = 2.4, radius = 0.6, data = { points = -20 } })

-- 2. Events: every peer hears them, late joiners included.
Skyfall.on("escaped", function(ev) if ev.kind == "star" then loseLife() end end)
Skyfall.on("removed", function(ev) if ev.reason == "caught" then addScore(ev.data.points) end end)

-- 3. When play starts: the authority creates the director (other peers get a handle to it).
local dir = Skyfall.director({
	name = "Skyfall",
	area = { center = {0, 6, 0}, width = 14, height = 10, depth = 2, down = {0, -1, 0} },
	look = "pastel", warning = "ring", entry = "popIn", curve = "easeIn", maxAlive = 40,
})

-- 4. A 90-second round that ramps up (authority only; harmless elsewhere).
Skyfall.run({ seconds = 90, curve = "easeIn", every = 3, waves = {
	{ pattern = "rain",  kinds = { "star", "star", "gloom" }, count = 6, gap = 0.4 },
	{ pattern = "vee",   kinds = { "star" }, count = 7, gap = 0.15 },
	{ pattern = "sides", kinds = { "star", "gloom" }, count = 6, gap = 0.3, motion = "float" },
} })

-- 5. Catching: from any peer (forwarded to the authority).
Skyfall.remove(entity, "caught")

Quick start (no code)

Add a SkyfallDirector component to an empty entity in your scene and press play. With autoRun on (default) it runs a looping round of rain from its fields: look, pattern, motion (empty = each kind's own), curve, seconds, rate (objects per second at the start), waveEvery, kinds (comma list), areaCenter, areaSize ({width, height, depth}), down, warning, entry, maxAlive, speedScale, loop.

The play area

A rectangle in world space: center, width (across), height (along "up"), depth (thickness; swirl and float use it), and down, the direction things fall. {0,-1,0} is a vertical field seen by a fixed camera looking along -Z; for a top-down area pass the screen's down, e.g. {0,0,1} (depth then runs along world Y). across may be given to override the left-to-right axis. Objects start just outside the edge their motion enters from (above for falling motions, below for arc and rise, beside for the sides pattern) and escape when they leave by any edge (ev.edge = bottom, top, left, right, or timeout after 45 s).

API

CallWhereWhat
Skyfall.VERSIONany"1.0.4"
Skyfall.defineKind(name, def)every peerdef = { build = function(entity, look) end?, model?, material?, tint?, shape?, motion?, speed?, radius?, data? }. build gets the object's local body entity to parent your visuals under (it is moved for you); or give a model / material; or a built-in shape. Built-in kinds orb, star, gem, bubble, balloon, rock, fruit, bomb, drop, leaf exist already.
Skyfall.director(opts) -> handleanyCreates (host) or finds the synced director named opts.name (default "Skyfall") and makes it current. Options: area, look, warning, entry, curve, pattern, motion, maxAlive, speedScale, kinds, autoRun. Handle: h.name, h:id(), h:entity(), h:isAuthority(), h:fields().
Skyfall.spawn(kind, { motion?, x?, y?, vx?, speed?, delay?, data?, look?, radius? }) -> entity?authorityOne object. x 0..1 across, y 0..1 up (default: the motion's own start edge), vx sideways m/s. nil elsewhere or at maxAlive.
Skyfall.wave({ pattern, kinds, kind?, count, gap, motion?, speed?, lanes?, data?, delay? }) -> { entity }authorityOne wave now.
Skyfall.run(schedule, opts?)authorityA list of waves ({ at = seconds, pattern = ..., ... }; missing at = previous + opts.every), or a round { seconds, waves, curve, every, strength?, loop? } that fires the next wave template every every seconds with count, speed and pace scaled by the curve. The schedule is stored in synced fields, so a new host carries on.
Skyfall.stopAll()authorityStops the schedule; objects in play keep going.
Skyfall.clear()authorityEnds everything in play (removed, reason "cleared").
Skyfall.remove(entity, reason?)anyEnds one object now (removed, reason default "removed"); forwarded to the authority from other peers.
Skyfall.alive() -> { entity }anyObjects in play on this peer.
Skyfall.positionOf(entity) -> {x,y,z}anyThis peer's computed position now.
Skyfall.infoOf(entity) / Skyfall.isObject(entity)any{ kind, data, motion, look, appearsAt, ended, radius }.
Skyfall.on(name, fn)any"spawned", "escaped", "removed" or "*" (fn(name, ev)). ev = { entity, id, kind, data, position, motion, director, reason?, edge?, appearsAt }. Returns a connection with :Disconnect().
Skyfall.isAuthority() / Skyfall.running()anyWhether this peer drives; whether a schedule runs.
Skyfall.setLook(name) / Skyfall.configure(opts)authoritySwitch look (objects in play too) / change director settings.
Skyfall.area()anyThe current play-area frame { c, ax, up, dz, w, h, d }.
Skyfall.looks() motions() patterns() entries() warnings() curves() shapes()anyThe style names.
Skyfall.stats()anyEvent counts and alive count on this peer.

Each object's synced SkyfallObject component also exposes its kind and gameData fields directly, for kits that hold the entity (e.g. a touch-target kit): entity.component.get(Skyfall.OBJECT).kind.

Gallery demo: require("skyfallKit.gallery").start({ center = {0,6,0}, cycleLooks = true }), .stop().

Multiplayer rules

  • One authority: the peer that owns the director entity (the host creates it with entity.spawnSynced; with host migration the new owner takes over, schedule included). Only it spawns, runs schedules and clears. Other peers' spawn / wave / run return nil / {} / false and do nothing.
  • Objects carry parameters, not transforms. Each object is a synced entity with a SkyfallObject component holding its start time on multiplayer.sessionTime(), start point, motion, speed, seed and the play area. The synced entity never moves; every peer computes the pose every frame and moves a local body child, so motion is smooth everywhere and no poses are streamed.
  • Endings are fields. The object's owner sets endReason (escaped / removed / cleared / your reason) and despawns it 0.3 s later; every peer fires the event from that field. An entity despawned by anything else fires removed with reason "despawned" on every peer and simply drops out of alive().
  • Late joiners receive live objects with the room snapshot; each fires spawned on them as it arrives.
  • defineKind on every peer: a kind's build is a function and cannot cross the network.

Performance

  • Network: one synced entity per object, one message when it spawns and one when it ends. No per-frame traffic.
  • CPU: measured on an Android phone with 40 objects alive: about 0.06 to 0.1 ms per object per frame (around 3 ms for 40), most of it the per-component update and three transform writes. maxAlive (default 40) caps it.
  • Draw: 2 to 6 primitive meshes per object for the placeholder looks; a game's own build decides its own cost.

Known limitations

  • Motion is deterministic per peer, but peers agree only to the accuracy of the session clock (typically a few tens of milliseconds), which is fine for catching but not for frame-exact physics.
  • Objects do not collide with anything; hit tests are the game's (use Skyfall.positionOf or the body entity).
  • fadeIn fades the tint in from white (the placeholder materials are opaque), not the opacity.

Guides in this package

  • how-to-make-things-fall-from-the-sky-in-waves-for-an-arcade-game — the concepts, every style, schedules, curves, multiplayer and performance.
  • example-build-a-catch-the-falling-stars-game — a step-by-step small game with lives, score and a difficulty ramp.

Version history

  • 1.0.4: runs on spawnerKit 1.2.7 (its README and version label now match; no code change in either kit).
  • 1.0.3: runs on spawnerKit 1.2.5, which keeps every pooled object (prewarmed ones too) fully asleep until it is used and stops refused-write warnings on peers that do not own an enemy.
  • 1.0.2 — declares spawnerKit (its difficulty curves) as a dependency, so installing skyfallKit on its own brings spawnerKit along.
  • 1.0.1 — an entry effect is no longer spawned under an object whose synced entity is already gone.
  • 1.0.0 — first release.