Skip to content

Cinematics ​

A cinematic flies the camera over the map, follows units, plays clips and lines of dialogue, with the HUD out of the way and the player's hands off: an intro, a boss's entrance, a conversation. You make one as data in the editor's timeline, as a script in code, or both.

Quick start ​

ts
import type { Cinematic } from '@v12-engine/client'

export const intro: Cinematic = async (cut) => {
	await cut.camera({ at: { x: 4, z: 30 }, distance: 20 })
	await cut.camera('gate', 6) // fly to the map's view "gate" over 6 s
	await cut.say('td.commander', 'Here they come.')
}

// in the view
cinematics: { defs: { 'td.intro': intro } }

// play it from the rules (the game waits while it plays) or from the view
playCinematic(world, 'td.intro', { hold: true })
client.play('td.intro')

Black bars come in, the camera flies to the gate, the commander speaks, and Esc skips it all.

Pages ​

PageWhat
Make a cinematic in 5 stepsfrom an empty timeline to playing it in the game
The timelinelanes, keys and clips, the clock, the Cinematic panel
Cameras and shotsshots, rails, follows, transitions, the screen and the picture
Dialoguelines, speakers, portraits, choices, title cards, subtitles
Music and soundmusic, stingers, sounds, voices, video
Triggering from a missionthe rules, cues, regions, scripted fights, cinematic scenes
File format referenceevery field, lane, hook and option; lanes of your own; tests

Three rules ​

  • Screen only, and fair. A cinematic reads the game through the session's snapshots and changes it only by commands, so what a story decides is in the replay and the same on every screen. hold (the game waits) is local and never makes a server wait for one player.
  • Its own clock. Every tween, wait, line and lane runs on the cut's clock, which has a rate, pauses, seeks and loops. That is how the editor scrubs and the pause menu holds a cinematic.
  • Lanes are plugins. The camera, dialogue and the rest use the same public lane API your own lanes use.

Data or code ​

  • Data: lanes of keys and clips on a clock, in cinematics/<id>.json (CinematicDef), made in the editor.
  • Code: an async function given a Cut (Cinematic).

They drive the same lanes through the same calls. A script plays data (cut.play(def)), data calls code (hooks at markers, cues), and a view entry can have both: the data plays under the script.

ts
cinematics: {
	defs: {
		'td.overlook': overlook, // data: played as it says
		'td.boss': bossEntrance, // a script
		'td.intro': { def: intro, play: introCode, back: true } // both: the data plays under the script
	}
}

With both, the cinematic is over when both are; with manual: true the script plays the data itself (cut.play('td.intro')).