DoomFaceBus.module
README.md
DoomFaceBus
Co-op marine-facing relay. Each client's DoomCamera publishes its local
player's horizontal look facing (faceX/faceZ) over the multiplayer RPC
channel, keyed by the player's account userId; every peer records the latest
facing per user. DoomPlayerBody reads it to orient a remote marine's
8-directional billboard.
Exports
Bus.ensure()— register the receive handler once per client (idempotent).Bus.publish(userId, fx, fz)— broadcast this client's facing and record it locally.Bus.get(userId) -> { x, z } | nil— latest facing recorded for a user.
Usage
local FaceBus = require("DoomFaceBus")
FaceBus.ensure()
FaceBus.publish(localUserId, lookX, lookZ) -- owner side
local rec = FaceBus.get(ownerUserId) -- remote side
Notes
- The
userIdis the cross-peer-stable identity carried on the syncedPlayercomponent, so the lookup resolves unambiguously on every client regardless of room peer ids or avatar respawns. Bus.ensure()latches registration at module scope; the require cache keeps every requiring component sharing one handler and onefaceByUsertable.