Skip to content

The timeline ​

A cinematic is lanes on a clock, like a film editor's timeline. A lane holds keys (a value at a time, joined by a curve: where the camera is) or clips (something that starts at at and lasts for seconds: a line, a letterbox). Keys are sampled, so scrubbing is free; clips start, run and end. Times are seconds, whatever the tick rate.

Quick start ​

ts
const playing = client.cinematics.play('td.intro', { rate: 0.8 })
playing.pause()
playing.seek(4)
playing.resume()
const outcome = await playing.done // 'ended' | 'skipped' | 'stopped' | 'replaced' | 'ignored'

Play a cinematic at 80% speed, pause it, jump to 4 s, go on, and hear how it ended.

Common tasks ​

Queue cinematics ​

ts
await client.cinematics.queue('td.boss', { interrupt: 'queue' }) // after the one playing; 'replace' or 'ignore'
client.cinematics.preload('td.boss') // voices, sounds and models ahead of time
client.cinematics.current // the one playing, or null
client.cinematics.onChange((playing) => transport.show(playing))

Loop a stretch until a click ​

ts
const flying = cut.play('menu-flyover')
await cut.untilClick()
cut.endLoop()
await flying

The def's loop: { from, to } plays that stretch over and over until cut.endLoop(), cut.end() or a skip: a menu's fly-over behind its buttons.

Split a long cinematic into sections ​

Markers of kind: 'section' (Shift+M in the panel) split it; cut.section('valley') plays one, from its marker to the next.

Put a cinematic inside another ​

json
{ "at": 4, "include": "gate-falls", "for": 6 }

A control lane's clip plays that cinematic from its moment, on the outer's clock. In code: cut.play(def | id, { at }).

Preload what it needs ​

preload: { types, models, sounds } on the def, with the sounds its lanes name, loads with client.cinematics.preload(id) or cut.preload(ids, { types, models }).

Editor ​

The Cinematic panel (bottom drawer of the map editor):

  1. Pick a cinematic or New (from nothing, or from a track of the old tracks.json); Duplicate, Rename, Delete.
  2. Lanes are on the left: mute, solo, lock, fold, drag to reorder; Lane adds one of any kind.
  3. On the right: the ruler (seconds and frames at 30), markers, clips as bars and keys as diamonds.
  4. Space plays from the playhead; drag the playhead to scrub; the view shows exactly what plays.
  5. Select an item to edit it in the Inspector.

Editing keys ​

ToDo
selectclick; Shift+click adds; drag a box from empty space; Ctrl+A; Esc
movedrag (snaps to items, markers, the playhead, seconds, frames within 6 px; Ctrl/⌘ off); Alt drags a copy
trim, splitdrag a clip's edge; S splits at the playhead
adddouble-click a row or its +; K keys the camera; M adds a marker
copy, cut, paste, duplicateCtrl+C, X, V, Ctrl+D; Delete
move the playhead←/→ a frame, Ctrl+←/→ a second, Shift+←/→ a marker, , and . the previous/next key, Home, End
nudgeAlt+←/→ a frame, Alt+Shift+←/→ a second
insert or remove timeCtrl+Shift+T puts a second in; Ctrl+Shift+Delete removes between in and out points
transportShift+Space stop; speed 0.25×–4× (Shift+, and Shift+.); I and O in/out points; L loop; Ctrl+Shift+X clears
zoomwheel over the ruler or Ctrl+wheel; Shift+wheel scrolls; + − zoom; 0 fits; Alt+0 fits the selection
record a camera moveR: play and fly the view; the take is simplified into a few keys
the scriptShift+S: every line in order, edited as text
copy as codethe </> button: the cinematic as a line of cinematics.defs
templatesInsert: Intro, Outro, Dialog exchange, Explosion beat, Duel, or a snippet you saved

Two items at once of a lane go on two lanes: what is dragged onto another item of its kind stops against it. Items can be pinned to a marker or another item (the Inspector's Pinned to), and lanes put in groups (right-click a lane). Every change is an undo step, saved with the map (Ctrl+S).

The preview ​

The panel plays with the game's own director and cut on a stage made of the editor (CinematicPreview): the camera, the screen pass, the HUD's dialog box, the map's units playing clips. It stands paused at the playhead, so dragging the playhead is a seek. The game's hooks don't run unless the code button is on. Params (the sliders button) are what the panel hands the cinematic.

The preview runs a world of the map (PreviewWorld, a LocalSession as Play here makes) that moves only with the cinematic's clock: orders, director commands, fights and waits on the world work there. A scrub reloads the nearest checkpoint (a save each second of play) and runs forward to the moment.

Reference ​

The clock (cut.clock, a CutClock) ​

  • Pause holds everything: the camera stands, lines stay. The pause menu holds every cinematic; playing.pause() in code.
  • Rate: playing.rate(0.5) or rate: 0.5. The game underneath has its own speed (hold stops it).
  • Seek: playing.seek(3) puts the lanes where they are at 3 s; a line spanning the time shows with what is left; a unit's clip plays from part way. A script's own steps go on from where they are. startAt: 2 seeks as it begins.
  • Loop: clock.loop = { from, to }.

Play options (PlayOptions) ​

From the def's play, then the view's entry, then the call:

OptionWhat
holdthe game waits while it plays (where it runs in the page)
skippableEsc skips it (true)
letterboxbars above and below: true, false, or a ratio (2.39)
backthe camera goes straight back after; otherwise it eases back
holdInputthe player's hands are off but the HUD stays: a tutorial
hudparts of the HUD that stay (['minimap', 'objectives'])
rate, startAtclock speed, and the second it starts at
params, manualwhat it is handed; a script of data and code plays the data itself
seedthe hand-held camera's noise (from the id by default)

client.play(what, options) settles with whether it played to its end. One playing makes way for a new one (replaced).

Panel functions ​

The panel's edits are plain functions (cinematicEdits in @v12-engine/editor: moveSelection, trimItem, paste, splitAt, addMarker, addLane, itemsInView; insertTime, removeTime), as are recording (simplifyTake, putTake, TAKE_EVERY, TAKE_TOLERANCE), snippets (cinematicSnippets: SNIPPET_TEMPLATES, insertSnippet, snippetOf, SnippetFiles), the script (cinematicScript: scriptLines, setLine, addLineAfter, addLineAt, deleteLine), the Inspector (setSelected, fieldOf, withField, setRef, freeRefName) and camera paths (cinematicPaths: cameraPaths, grabAt, moveKey, moveHandle). CinematicFiles reads and writes the files through editor.files. editor.panels.api('cinematic') opens one (open(id, at)), runs an action (run('loop')), plays it in the game (playInGame()), and hands out its preview (time, running(), play, pause, seek, setRate, setLoop, next, held, stage, screen, world with catchingUp and settled()).

Files in the editor ​

The editor reads every file of cinematics/ and follows changes on disk or in another tab (editor.cinematics: ids(), defs(), failed()). ⌘K finds a cinematic by name and a marker by its (c gate). What a cinematic names (units, regions, views, paths, included cinematics, refs) is checked against the map; a missing name is a warning in Problems (rule cinematic), with where it is. Snippets are files of cinematics/snippets/<name>.json.