In this tutorial we will try to display an Ink story in Godot 4.
If you don’t know about ink, it’s used in narrative video games for the dialogs, for making complex branching for example.
You can find more informations on the official website : Ink
To enable Ink in our game we will use a plugin : godot-ink
The first step is to download the latest version of the plugin.
Then we can create a project in Godot :
After the project is created you can import the plugin by extracting the archive and drag and drop the folder addons like this
To generate the csproj file you will need to edit, you need to go to Project like this :
The next thing to do is to add this line inside the csproj file before the end of the
<Import Project="addons\GodotInk\GodotInk.props" />
You should have something like this for this file :
<Project Sdk="Godot.NET.Sdk/4.1.1">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
</PropertyGroup>
<Import Project="addons\GodotInk\GodotInk.props" />
</Project>
After that you need to run your project but we need to create the main scene first.
Select the 2D Scene on the scene menu :
After the node is created you can save the scene with ctrl+s and name it scene1 for example :
You can now run the project, everything should be working fine, for the moment we don’t have anything to display.
You can now enable the plugin for that go into the Project -> Project Settings :
The next thing to do is to import a story and try to display it, to find an example for a story you can download one on github :
https://github.com/inkle/the-intercept/blob/master/Assets/Ink/TheIntercept.ink
After the story is imported you need to reimport it to enable some flag, go into the import menu and check Is Main File to On then Reimport :
After that you can test the story in the Ink preview :
Click on Load and select the Story, you should then be able to play the story like this :
In the Node2d create a VBoxContainer then attach a new C# script to this container and call it QuickStartGuide.cs :
using Godot;
using GodotInk;
public partial class QuickStartGuide : VBoxContainer
{
[Export]
private InkStory story;
public override void _Ready()
{
ContinueStory();
}
private void ContinueStory()
{
foreach (Node child in GetChildren())
child.QueueFree();
Label content = new() { Text = story.ContinueMaximally() };
AddChild(content);
foreach (InkChoice choice in story.CurrentChoices)
{
Button button = new() { Text = choice.Text };
button.Pressed += delegate
{
story.ChooseChoiceIndex(choice.Index);
ContinueStory();
};
AddChild(button);
}
}
}
After attaching the script you should see it in the inspector like this :
If you don’t see it like me, you can save and close your project and reopen it. Everything should be set, if you reloaded the project check the import of the story is correct before running the project, for me the flag is main file was disabled. The end result should look like this : You can download the end project below :
Assign the story to the script by dragging and dropping inside the