Log inGet started
Package

DoomFaceBus.module

Newest version

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 userId is the cross-peer-stable identity carried on the synced Player component, 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 one faceByUser table.