Log inGet started
Package

crashRig.package

This package holds more than this page lists. See all of its files in its world.

README.md

recorder

Records what this peer draws of a hierarchy and plays it back as local ghosts, at any speed. It exists because the engine has no record and playback of the simulation (#20544). The CrashRig component uses it for the slow-motion replay; any game can use it for kill-cams or instant replays.

  • Rec.new{ roots, track, hz = 60, maxSeconds = 8, ghostLayer = "default" } creates a recorder.
    • roots are entity ids whose whole hierarchy is recorded: every entity with a Model, plus the particles of every SoftBody under them.
    • track adds entities to record even without a Model, such as a camera target.
  • rec:start(), rec:stop(), rec:duration() and rec:frames() control and report the recording. Recording rescans its roots every 0.1 s, so pieces that appear later, like a panel coming off, are caught.
  • rec:addRoot(id) and rec:addTrack(id) add to a recording that is already running.
  • rec:trim(t0, t1) keeps only that window, in seconds since the start.
  • rec:play{ speed = 0.25, loop, onFrame, onDone } plays it back and returns { stop(), time(), playing(), ghostOf(id) }.
    • It spawns local, temporary ghosts: a Model for each rigid piece, and a non-colliding soft body for each soft body, whose particles are written every frame, so dents replay as they formed.
    • ghostOf(id) gives the ghost standing in for a live entity, to aim cameras at.

Nothing crosses the wire: each peer replays what it drew. Hide the live entities from the replay camera with a render layer. The rig puts them on crash, so its replay camera draws "all !crash".