Yarn Spinner for Godot
The third step in our beginner's guide, focusing on getting up and running with Yarn Spinner for Godot.
Yarn Spinner for Godot is a Yarn Labs project. It is not fully, or officially supported, and may break, or change at any time.
This step of the beginner's guide helps you move from writing Yarn scripts outside of a game engine, to initial integration steps to turn them into a game with Godot
First, launch Godot 4.1 (C# version) and create a new project.
addons/directory in your new local copy of Yarn Spinner for Godot:
addonsdirectory in a local copy of Yarn Spinner for Godot.
Put a copy of this directory into your new Godot project, either by dragging the folder in your file manager (e.g. Finder or Explorer) into the folder of the Godot project, or by dragging from your file manager into the FileSystem dock of your Godot project:
The FileSystem dock in Godot, after dragging the
Next, choose the Project menu -> Tools -> C# -> Create C# solution. This will create a C# project for you. We have to do this to trigger the creation of the
.csprojfile, which is necessary to let Godot know about the Yarn Spinner plugin.
Next, open the project folder in Visual Studio Code. In the sidebar of VS Code, the
.csprojfile and add the following line to it, inside the
</Project>tags, but not inside an
<Import Project="addons\YarnSpinner-Godot\YarnSpinner-Godot.props" />
Your brand new project should look something like this in VSCode:
.csprojfor your project.
Save the tweaked
.csprojfile and return to Godot, everything is almost ready to go. Click the Build button in the very top right-hand corner of the Godot window. This will trigger a build of the C# solution for the project, which is required to make Godot aware of Yarn Spinner for Godot.
Once the build is complete, open the Project menu -> Project Settings, change to the Plugins tab, and tick the enabled box next to the Yarn Spinner for Godot plugin:
The Project Settings, showing the Plugins tab.
With that, you're ready to go!
In your Godot project, click the Instantiate Child Scene button:
The chain-link button, for instantiating a child scene.
And navigate into the
addons/YarnSpinner-Godot/Scenesfolder of your project, and choose the
DefaultDialogueSystem.tscnfile as the scene to instantiate:
Choosing the provided
Your Scene dock will look like this showing a node hierarchy that's entirely based on the
DefaultDialogueSystem.tscnscene that you instantiated:
DefaultDialogueSysteminstantiated into your scene.
You could also instantiate the
DefaultDialogueSystem.tscninto your scene at a lower part of the hierarchy, instead of the root node, to display dialogue using the provided default UI, instead.
Next, create a new Yarn Project by right-clicking in the FileSystem dock, and choosing Resource...:
Creating a new Resource in the FileSystem dock.
Then filter to the
YarnProjectresource type, and click the Create button:
Creating a new YarnProject resource.
Name the new Yarn Project
Next, create a new Yarn script (a file with a
.yarnextension) by right-clicking in the FileSystem dock, and choosing New TextFile:
Creating a new TextFile, in order to add a Yarn script.
In the resulting New Text File... window, select All Files (*) from the dropdown in the corner, set the File name to
MyStory.yarn, and click the Save button:
Naming the file for a new Yarn script.
It may take a moment, but Godot will import your new
.yarnfile, and it will appear in the FileSystem dock. When it's appeared, double-click on the Yarn Project,
FirstProject.tresin the FileSystem dock and look to the Inspector, making sure that
res://MyStory.yarnis in the list of Source Scripts, which are the Yarn scripts that compromise the new project:
The Yarn Project, with the Yarn script identified as a Source Script.
Next, open the
MyStory.yarnfile in VS Code, and add the following Yarn script to it, before saving it and returning to Godot:
Select the the
DialogueRunnernode in the Scene dock, and look to the Inspector. Assign the Yarn Project you created to the
DialogueRunnerby dragging the
FirstProject.tresYarn Project from the FileSystem dock into the Yarn Project slot of the Inspector:
The new Yarn Project resource assigned as the Yarn Project for the
Startas the Start Node, and tick the box next to Starts Automatically:
Setting the Start Node, and that we want this
DialogueRunnerto start automatically.
Save your scene as
Demo.tscn, and run the game. At this point, you can play your project, and step through the dialogue in the default Yarn Spinner for Godot Line View and Options List View:
With that, we've reached the end of our beginner's guide. You're ready go forth and build games with Yarn Spinner! You're also equipped to work with the rest of the documentations here! Don't forget to join the Discord to chat with other Yarn Spinner users, the Yarn Spinner team, seek help, and share your work.
Last modified 1mo ago