Months ago, while preparing the Gamelab 2015 build of Trespassers, we were thinking about how could we tell bits of the story inside the game. But things were that we had no time to develop a full cinematic for every bit of the story we wanted to share. This was time consuming, hard, and we had not so much time left to prepare our demo build, which was of utmost importance.
But, as we love classical graphic adventure games, we were predisposed to do something with scripting languages at a higher level than C# (our language of choice for Unity). We wanted to skip all that hassle of scripting a cinematic in code, we wanted something readable, simple, in a word. We came up with a solution in no time: our own simple scripts (and parser) for the scenes. Let’s check how do they look like:
// Columns follow this rules:
// ACTION CHARACTER_ID ACTION_SPECIFIC_ATTRIBUTES
// One-line comments are accepted at the start of the line
// Each token is separated by \t
// LOOK_AT P1 P2
// TALK P1 "Hey dude, this seems strange"
// Valid verbs:
// lookAt who where secondsToWait
// talk who text
// mute who seconds restoreAnimator
// goTo who position
mute P1 0
mute P2 0
lookat P1 right 2
lookat P1 left 1
lookat P1 right 1
lookat P1 P2 0.5
talk P1 "Hey dude" 0.25
talk P2 "Yeah?" 0.5
talk P1 "My beer-sense tells me that ..."
mute P1 1
talk P1 "there must be a BIG BARREL of BEER, dude"
mute P2 0.5
lookat P2 left 1.2
lookat P2 right 1.2
talk P2 "Bad place for beer"
talk P1 "We must protect it from green-green dudes"
mute P1 0 true
talk P2 "Guns loaded, bro!"
mute P2 0 true
talk P1 "Bro loaded, guns!"
mute P2 1
lookat P2 left 0.5
lookat P2 right 0.5
mute P2 1
talk P2 "How did we end 'ere?"
mute P2 1 true
(The MS DOS formatting option seemed like the best for readibility. And it is retro, so yeah, fits the theme)
This kind of snippets have two main advantages (and a big limitation, too)
- Simple: even without the comments above the text, you could easily understand what may happen, it is non-programmer friendly. Non-programmers can edit and generate this snippets easily, so the only lonely programmer can spend his time at other tasks.
- Text, not code: the code is executed by the parser, the CutSceneManager (as we call it). It converts the lines to real commands that get queued and executed sequentially, till no more are left. The main advantage is that we have no need to recompile the entire project, thus it helps reducing debug time. And designers fear less dealing with it. Well, the designer is the programmer in this project, so what the …
The main limitation is that it is … well, limited. Don’t expect anything too fancy, although of course you could further develop the system to get additional features, but simple was our keyword. The results are more than enough to give a small chance to reach the audience, and help us reducing the time needed to insert halts in the frenzy action when needed.
We hope that it helps improving your workflow or, at least, sparks your creativity towards your custom solution.