Pardon our dust while we move our docs here. The Godot (GDScript) docs are on this site, and the Yarn language, Unity, Godot (C#) and Unreal docs are still at docs.yarnspinner.dev.

Simple 3D is the smallest 3D setup in the samples. Capsley stands in a small arena between two trees, and says one line, “Hello!”. There’s no player to move and nothing to set up in code. The dialogue comes from the shared dialogue scene in samples/shared, with only its Yarn Project changed.

A blue capsule character with a face, a red tie and a badge, holding a coffee cup, stands on a grey checked floor between two green trees, with a bright sun in the sky behind. A dark dialogue box across the bottom shows the name Capsley and the line Hello!
Capsley's one line.

Running it

Open samples/simple_3d/simple_3d.tscn and click Run Current Scene. The dialogue starts by itself.

  • Press Enter or Space, or click, to show the whole line or end the dialogue.

How it works

Simple3DNode3D
DirectionalLight3D
Camera3D
CharacterBody3D
DialogueNode
YarnDialogueRunner
UILayerCanvasLayer
LinePresenterControl
OptionsPresenterControl
BasicArenaNode3D
tree-large2Node3D
tree-small2Node3D
simple_3d.tscn, with the shared dialogue scene opened up.

The scene is made almost entirely of shared pieces from samples/shared:

  • CharacterBody3D is Capsley, from samples/shared/scenes/explanation_character.tscn.
  • BasicArena is samples/shared/scenes/Basic Arena.tscn, the floor and low walls.
  • Dialogue is samples/shared/scenes/dialogue.tscn, with Editable Children turned on.

The shared dialogue scene has almost everything the dialogue needs. Its YarnDialogueRunner has Auto Start on, its Start Node is Start, and its Presenters are the shared LinePresenter and OptionsPresenter from samples/shared/ui. It has no Yarn Project, because each scene that uses it sets its own. Here, Editable Children is turned on for the Dialogue instance, and the YarnDialogueRunner’s Yarn Project is set to Simple3D.yarnproject. The Welcome sample uses the same shared scene in the same way.

The whole Yarn Script is one node:

title: Start
---
Capsley: Hello!
===
Simple3D.yarn.

To get the same dialogue in your own 3D scene, add a Dialogue Runner with a Yarn Project, a Line Presenter and an Options Presenter on a CanvasLayer, and turn on Auto Start. Nothing about it is specific to 3D.

Adding Presenters from code

The root node’s script, simple_3d.gd, is all comments. It shows the other way to give the Dialogue Runner its Presenters, which is to add them in code rather than listing them in the Inspector:

extends Node3D

# @onready var dialogue_runner: YarnDialogueRunner = $Dialogue/YarnDialogueRunner
# @onready var line_presenter = $Dialogue/UILayer/LinePresenter
# @onready var options_presenter = $Dialogue/UILayer/OptionsPresenter

# # Called when the node enters the scene tree for the first time.
# func _ready() -> void:
# 	dialogue_runner.add_presenter(line_presenter)
# 	dialogue_runner.add_presenter(options_presenter)
simple_3d.gd.

Adding a Presenter that’s already in the list does nothing, so to try the code version, clear the Dialogue Runner’s Presenters first, then uncomment the code. Setting the Presenters in the Inspector, as this scene does, is usually simpler. See Adding Presenters.

Things to try

  • Add more lines to Simple3D.yarn, or some options. The shared Options Presenter shows them with no other changes.
  • Select Dialogue/YarnDialogueRunner and turn off Auto Start. Nothing happens when the scene runs, because nothing starts the dialogue.
Next step Feature Tour A 3D building where each room shows a different Yarn feature, with characters you walk up to and talk to.