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
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
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
const flying = cut.play('menu-flyover')
await cut.untilClick()
cut.endLoop()
await flyingThe 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
{ "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):
- Pick a cinematic or New (from nothing, or from a track of the old
tracks.json); Duplicate, Rename, Delete. - Lanes are on the left: mute, solo, lock, fold, drag to reorder; Lane adds one of any kind.
- On the right: the ruler (seconds and frames at 30), markers, clips as bars and keys as diamonds.
- Space plays from the playhead; drag the playhead to scrub; the view shows exactly what plays.
- Select an item to edit it in the Inspector.
Editing keys
| To | Do |
|---|---|
| select | click; Shift+click adds; drag a box from empty space; Ctrl+A; Esc |
| move | drag (snaps to items, markers, the playhead, seconds, frames within 6 px; Ctrl/⌘ off); Alt drags a copy |
| trim, split | drag a clip's edge; S splits at the playhead |
| add | double-click a row or its +; K keys the camera; M adds a marker |
| copy, cut, paste, duplicate | Ctrl+C, X, V, Ctrl+D; Delete |
| move the playhead | ←/→ a frame, Ctrl+←/→ a second, Shift+←/→ a marker, , and . the previous/next key, Home, End |
| nudge | Alt+←/→ a frame, Alt+Shift+←/→ a second |
| insert or remove time | Ctrl+Shift+T puts a second in; Ctrl+Shift+Delete removes between in and out points |
| transport | Shift+Space stop; speed 0.25×–4× (Shift+, and Shift+.); I and O in/out points; L loop; Ctrl+Shift+X clears |
| zoom | wheel over the ruler or Ctrl+wheel; Shift+wheel scrolls; + − zoom; 0 fits; Alt+0 fits the selection |
| record a camera move | R: play and fly the view; the take is simplified into a few keys |
| the script | Shift+S: every line in order, edited as text |
| copy as code | the </> button: the cinematic as a line of cinematics.defs |
| templates | Insert: 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)orrate: 0.5. The game underneath has its own speed (holdstops 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: 2seeks as it begins. - Loop:
clock.loop = { from, to }.
Play options (PlayOptions)
From the def's play, then the view's entry, then the call:
| Option | What |
|---|---|
hold | the game waits while it plays (where it runs in the page) |
skippable | Esc skips it (true) |
letterbox | bars above and below: true, false, or a ratio (2.39) |
back | the camera goes straight back after; otherwise it eases back |
holdInput | the player's hands are off but the HUD stays: a tutorial |
hud | parts of the HUD that stay (['minimap', 'objectives']) |
rate, startAt | clock speed, and the second it starts at |
params, manual | what it is handed; a script of data and code plays the data itself |
seed | the 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.