Skip to content

Make a cinematic ​

A cinematic is a script of camera, dialog and screen steps. Write it in code (Cinematic), or on a timeline in the editor's Cinematic panel, which writes cinematics/<id>.json.

ts
// in src/cinematics.ts
import type { Cinematic } from '@v12-engine/client'

/** The intro: the camera over the gate, a word, and the file made in the editor with code around it */
export const intro: Cinematic = async (cut) => {
	await cut.screen.letterbox(2.39, 0.4)
	await cut.shot({ at: { x: 4, z: 30 }, distance: 20, pitch: 0.7 }, { seconds: 2, ease: 'inOutCubic' })
	await cut.say('commander', 'Here they come.')
	await cut.orbit({ x: 30, z: 30 }, { radians: Math.PI / 2, seconds: 3 })
	await cut.play('mygame.overlook') // the file made in the editor, as a step
	await cut.screen.reset()
}

Name it in the view, with any files the editor made:

ts
// in src/game.ts: named in the view, with the files the editor made
import overlook from './cinematics/overlook.json'
import { readCinematic, type GameView } from '@v12-engine/client'

export const view: GameView = {
	units: {
		looks: {}
	},
	cinematics: {
		defs: { 'mygame.intro': intro, 'mygame.overlook': readCinematic(overlook) },
		speakers: { commander: { name: 'The commander', color: '#e0c060' } }
	}
}

Play it from the screen or from the rules (the rules play it on the screens it's for, in replays too):

ts
await client.play('mygame.intro', { hold: true, skippable: true }) // 'ended' | 'skipped' | …
playCinematic(world, 'mygame.intro', { hold: true }) // from the rules
// in a sequence, waited for: the step `cinematic('mygame.intro', { hold: true, wait: 'ended' })`

Done: the intro letterboxes, flies the camera to the gate, says a line, orbits, plays the editor's shot, and resets. Esc skips.

Play a cinematic before the game ​

Use cinematicScene; see Add a scene.

In the editor ​

  1. Open the Cinematic panel. Each lane is a row on a clock: camera, screen, dialog, audio, effects, interface.
  2. Add keys and clips, and scrub the clock to preview.
  3. Add markers: code waits for them with untilMarker and fires cues on them.
  4. Click Play here to watch it in the game. It's saved to cinematics/<id>.json.

Reference ​

Steps you await run in turn; steps you don't run together.

Areacut calls
Camerashot, follow, orbit, dolly, zoom
Screenscreen.letterbox, fade, vignette, tint, screen.reset
Dialogsay, dialog.*, choose
Soundaudio.music, stinger
Worldclip, where, spawn (through the rules' cues)
Waitingwait, until, untilMarker
Filesplay(id): a file's lanes as one step

Cinematics has every call, lanes, refs and params, and testing.