Sponsored By

A short overview of how we implemented a basic Unity framework for narrative games written in Ink.

Marcus Bäumer, Blogger

January 3, 2019

3 Min Read

Hello friends of narrative games, and oh, hello 2019!

The last couple of month have been busy for us. We’ve been working on some smaller comissional work, but mainly implemented the basic framework for our upcoming title Resort. This is going to be a rather technical post that’ll introduce the basic structure of our new framework.

We’re using Unity as a game engine for our games. Given the fact that we’re a very small team, we’re open to using plugins from the Unity Asset Store to save time and resources. For Unforeseen Incidents, we used Adventure Creator, a great asset when it comes to developing classic style point & click adventures.

However, relying on plugins for very basic functionality also proved to be a source for frustration and lead us to developing our own core framework for our new and future projects.

For writing the story and dialogs, we decided to switch to Ink, a scripting language by Inkle which allows for a very free and creative writing process. The script of the whole game is written in a simple and pure text editor. Basically, the whole logic of on story flow can be implemented directly within Ink.

In the last weeks, we developed a system that allows us to create an explorative, narrative 3D game within Unity using Ink stories. Here’s a sketch of how the system works:

To avoid allocating memory, all story files get parsed before runtime. Our parser then creates a database of directions that are used in the game. Directions are commands within the Ink stories that look somewhat like this:

>>> TIMELINE intro runinbackground:true

The command above tells Unity to run a timeline called intro, and to not wait until its finished until it runs the next Ink command or displays the next dialog line of the script. We don’t want to parse and create the direction as runtime, since that would create a lot of garbage over time. We parse the string commands to Directions. Directions are ScriptableObjects holding references to Story Elements, the GameObjects in our scenes, and the logic that’ll be executed at runtime.

The game consists of more than one scene, thus Story Elements are spread over different scenes. To not lose the references, we use the excellent Cross Scene Reference script by William Armstrong. The Directions use cross scene references rather than direct references to the game objects.

The parser also creates a database for the dialog that allows us to translate the script to other languages, and create scripts for voice actors (in different languages). Lines of dialog in the Ink file simply look like this:

Laura: What are you doing there?

Using the Ink syntax, the whole game is written within pure text files. When the game runs, the Ink files are executed by the Director, following the logic in the stories. The Director uses the databases that have been created beforehand, and is responsible for executing the Directions and lines of dialog. The whole logic for the story sits within the Ink files, while all Story Elements are placed in the Unity Scenes.

Now that the basic system is implemented, we can start getting all the Ink files, 3D models and animations in the game! We’ll keep you posted about this process.

Join our Discord to not miss future updates!

Read more about:

Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like