Skip to content

Dialogue

ss-gameforge-dialogue types out a sequence of lines, one character at a time, inside a box that animates in and out. The same content works as a fixed box at the bottom of the screen (a top-down or side-view RPG) or as a speech bubble over a character, in 2D or in 3D.

Content lives in a DialogueResource, so writing dialogue never means touching the view. Who is talking is a DialogueSpeaker, and the look is a DialogueTheme.

  1. Download ss-gameforge-dialogue from the releases page.
  2. Copy addons/ss-gameforge-dialogue/ into your project’s res://addons/.
  3. Enable ss-gameforge-dialogue in Project Settings → Plugins.
ClassDescription
DialogueResourceThe lines, who says them, and every timing and animation setting.
DialogueViewControl that shows and animates a sequence, as a screen box or a speech bubble.
DialogueView3DNode3D speech bubble in world space; wraps a DialogueView.
DialogueSpeakerA character: name, name colour, portrait and typing voice.
DialogueThemeLook of the box: colours, border, texture, font, speaker name and portrait size.
DialogueHistoryLog of the lines shown, for a backlog screen.

Right-click in the FileSystem → New Resource → DialogueResource, and fill dialogues:

["Welcome, traveler.", "The path ahead is dangerous.", "Are you ready?"]

Or by code:

var resource := DialogueResource.new()
resource.dialogues = [
"The gate will not open without the seal.",
"Look for it in the [i]east wing[/i].",
]
resource.use_translation = false

A literal \n inside a line becomes a real line break.

Instance res://addons/ss-gameforge-dialogue/scenes/dialogue_view.tscn. It starts hidden and shows itself when play() runs.

The view fills its parent (the whole screen when it is not inside a container) and lets mouse input through. The box spans the width, sits position_margin above the bottom edge and grows upward to fit its text. If your game uses a Camera2D, put the view on a CanvasLayer so the camera does not move it.

@onready var dialogue_view: DialogueView = $DialogueView
func talk() -> void:
dialogue_view.dialogue_finished.connect(_on_dialogue_finished, CONNECT_ONE_SHOT)
dialogue_view.play(preload("res://dialogues/intro.tres"))
func _on_dialogue_finished() -> void:
print("done")

CONNECT_ONE_SHOT matters when one view plays many sequences: without it the callback stacks up on every play.

PropertyTypeDefaultDescription
dialoguesArray[String]—Lines (text or translation keys). BBCode allowed.
use_translationbooltruePass each line (and speaker names) through tr().
speakerDialogueSpeakernullWho says every line, unless line_speakers says otherwise.
line_speakersArray[DialogueSpeaker][]Per-line speaker by index. A missing or empty entry uses speaker.
auto_startboolfalsePlay when the view that holds it in resource is ready.
allow_skipbooltrueLet the player complete a line early or advance.
advance_modeAdvanceModeHYBRIDWho moves the dialogue forward (see below).
text_speedfloat0.075Seconds per character. Lower is faster.
time_to_startfloat0.25Delay between play() and the box appearing.
hold_after_linefloat0.75Pause before auto-advancing (AUTO / HYBRID).
open_timefloat0.55Open animation duration.
open_transition / open_easeTween enumsTRANS_ELASTIC / EASE_OUTOpen animation curve.
close_timefloat0.20Close animation duration.
close_transition / close_easeTween enumsTRANS_BACK / EASE_IN_OUTClose animation curve.
ModeBehaviour
AUTOAdvances on its own after hold_after_line. The hold cannot be skipped.
MANUALWaits for the player to press skip_action.
HYBRID (default)Whichever comes first: the player’s press or the hold_after_line timer.

In every mode, pressing skip_action while a line is still typing completes it instantly, as long as allow_skip is on.

PropertyTypeDefaultDescription
resourceDialogueResourcenullPlayed on ready when its auto_start is on.
dialogue_themeDialogueThemenullLook of the box. Empty = built-in dark style.
layoutLayoutSCREENSCREEN box or BUBBLE speech bubble.
input_modeInputModeAUTOWhere input is read from.
skip_actionStringNameui_acceptCompletes the line being typed, or advances.
back_actionStringNameemptyShows the previous line again. Empty = off.
hide_actionStringNameemptyHides every dialogue while held. Empty = off.
historyDialogueHistoryownWhere shown lines are recorded. Share one between views.
voice_busStringNameMasterAudio bus for the speakers’ voices.
func play(res: DialogueResource) -> void # Start a sequence (ignored while one is running)
func stop() -> void # Cancel and play the close animation
func skip() -> bool # Same as a skip_action press
func back() -> bool # Show the previous line again
func is_playing() -> bool # True from play() until dialogue_finished
func get_speaker() -> DialogueSpeaker # Who says the line on screen, or null
func apply_theme() -> void # Re-apply dialogue_theme (play() already does)
static func set_all_hidden(hidden: bool) -> void # Hide or show every dialogue
static func is_all_hidden() -> bool
signal dialogue_started # The open animation starts
signal line_changed(index: int) # A new line starts (0-based)
signal character_typed(character: String) # Each character as it is revealed
signal dialogue_finished # Once per sequence, after the close animation
signal bubble_resized(size: Vector2) # BUBBLE layout: the bubble changed size
  • play() is ignored while another sequence is running or closing, so calling it from an input handler is safe.
  • stop() is safe at any point, including during the start delay or the open animation. dialogue_finished fires once per sequence (not at all when stop() cancels during the start delay, since nothing opened).
  • The skip_action press that skips or advances is marked as handled, so it does not also reach gameplay. Presses during the open animation are swallowed, so the press that started a conversation never skips its first line.

layout decides where the box goes. The same resource, theme and API work with both, so one game can use a screen box for story scenes and bubbles for background chatter.

LayoutLooks likeFits
SCREENA box across the bottom of the view, growing upward.Top-down and side-view games with a fixed dialogue box.
BUBBLEA box sized to its text, wrapping at the theme’s bubble_max_width, with its bottom-centre on the view’s origin.Speech bubbles over characters, in 2D or 3D.

Put a DialogueView with layout = BUBBLE under a Node2D — a Marker2D above the character’s head works well. The bubble’s tail sits on that point and follows the character and the camera:

@onready var bubble: DialogueView = $HeadMarker/DialogueView # layout = BUBBLE
func talk() -> void:
bubble.play(npc_lines)

DialogueView3D is a Node3D that builds the world-space setup for you: a transparent SubViewport holding a DialogueView in BUBBLE layout, shown on a billboard Sprite3D, with the viewport resized to the bubble on every line. Place it where the tail should point and call play():

@onready var bubble: DialogueView3D = $Head/DialogueView3D
func talk() -> void:
bubble.play(npc_lines)

It forwards play(), stop(), skip(), back(), is_playing(), get_speaker() and the signals; get_view() returns the inner DialogueView for anything else. Sprite options:

PropertyDefaultDescription
pixel_size0.01World units per bubble pixel.
billboardtrueAlways face the camera.
no_depth_testtrueDraw over geometry, so walls and the speaker’s own mesh never hide the text.
fixed_sizefalseSame size on screen at any distance.

skip_action, back_action and hide_action are read according to input_mode:

ModeReads input from
AUTO (default)_unhandled_input events, marking the press handled. Inside a SubViewport that gets no events (one used as a texture, like in DialogueView3D) it polls instead.
EVENTSOnly events.
POLLINGInput.is_action_just_pressed() every frame, in any viewport. The press is not consumed.
NONENothing: drive the dialogue yourself with skip() and back().

skip() does what a press does and returns true when it did something, so you can forward input from your own system — for example, per player:

func _process(_delta: float) -> void:
if player.is_action_just_pressed("talk"):
bubble.skip()

A DialogueSpeaker resource describes who is talking. Make one per character and reuse it.

PropertyDefaultDescription
display_nameemptyShown above the text (through tr() when the resource uses translation). Empty = no name.
name_colortransparentColour of the name. Transparent = the theme’s name_color.
portraitnullDrawn beside the text at the theme’s portrait_size. Empty = no portrait.
voicenullShort sound played while the line types. Empty = silent.
voice_pitch1.0Base pitch; higher sounds smaller or younger.
pitch_variation0.05Random pitch change per blip (0.05 = ±5%).
voice_every2Blip every this many characters (spaces skipped).
voice_volume_db0.0Volume of the blip.

Set speaker on the resource for the whole sequence, and line_speakers to change speaker on given lines:

const ANA := preload("res://characters/ana_speaker.tres")
const BO := preload("res://characters/bo_speaker.tres")
resource.dialogues = ["Did you hear that?", "Hear what?", "Never mind."]
resource.speaker = ANA
resource.line_speakers = [null, BO] # line 1 is Bo, the rest Ana

It works the same in the screen box and in 2D/3D bubbles; a bubble grows to fit the portrait and the name. Skipping a line completes it silently.

For anything else per character — mouth flaps, your own sound system — connect character_typed(character).

Every line a view shows is written to its history, a DialogueHistory resource. Assign the same one to several views (screen box, 2D and 3D bubbles) to gather every speaker in one log:

var log := DialogueHistory.new()
func _ready() -> void:
$DialogueView.history = log
$Npc/DialogueView3D.history = log

Each entry is a dictionary with text, speaker, speaker_name, resource and index; text is the line as displayed (translated, BBCode included). The addon records; your game decides how the backlog looks:

func open_backlog() -> void:
for entry in log.get_entries():
backlog_list.append_text("%s: %s\n" % [entry["speaker_name"], entry["text"]])

max_entries (default 200, 0 = unlimited) drops the oldest, clear() empties it and entry_added fires with each new line. A view with no history assigned keeps its own.

back(), or a press of back_action, shows the previous line of the running sequence again, fully revealed. Going forward again does not record those lines twice.

Set hide_action and, while the player holds it, every dialogue (screen box, 2D and 3D bubbles) is hidden so the scene behind can be seen. They are not paused: lines keep typing and skip_action still advances. Releasing the button shows them again.

Bind hide_action to a button next to skip_action: the player holds it to look, lets go to read, and presses continue as usual.

From code, DialogueView.set_all_hidden(true) hides them all until set_all_hidden(false), independently from the button, and DialogueView.is_all_hidden() tells whether they are hidden. Views created while hidden start hidden.

Create via New Resource → DialogueTheme and assign it to dialogue_theme. Without one, a built-in dark style is used.

PropertyTypeDescription
background_colorColorBox fill. With background_texture set, it tints the texture.
border_colorColorBox border colour.
border_widthintBorder width in pixels.
corner_radiusfloatCorner radius.
paddingVector2Horizontal and vertical padding.
background_textureTexture2DOptional 9-slice texture that replaces the flat box (border and corner settings are then ignored).
texture_patch_marginintUnstretched border of the texture, in pixels.
font_colorColorText colour.
font_sizeintFont size.
fontFontCustom font. Empty = the project’s default.
name_colorColorSpeaker name colour, unless the speaker sets its own.
name_font_sizeintSpeaker name size. 0 = font_size.
portrait_sizeVector2Size the portrait is drawn at, keeping its aspect.
position_marginVector2SCREEN layout: distance from the left, right and bottom edges.
bubble_max_widthfloatBUBBLE layout: widest a bubble grows before its text wraps (default 320 px).
dialogue_view.dialogue_theme = preload("res://ui/my_dialogue_theme.tres")
dialogue_view.apply_theme()

The reveal is BBCode-aware: the whole line is laid out first and revealed with RichTextLabel.visible_characters, so markup never leaks and words never jump to the next line halfway through being typed:

"The [b]dragon[/b] awakens..."
"Your health is [color=green]full[/color]."
"[wave]Loading...[/wave]"

BBCodeParser is still available as a utility (visible_length(), prefix()) for your own code.

With use_translation = true, each string in dialogues is a translation key, and so is each speaker’s display_name:

dialogues = ["INTRO_LINE_1", "INTRO_LINE_2"]
use_translation = true

The view calls tr() before showing each line.

Advanced example — NPC with a 3D speech bubble

Section titled “Advanced example — NPC with a 3D speech bubble”
extends Area3D
@export var lines: DialogueResource
@onready var bubble: DialogueView3D = $Head/DialogueView3D
var _player_inside := false
func _ready() -> void:
body_entered.connect(func(b): _player_inside = b.is_in_group("player") or _player_inside)
body_exited.connect(func(b):
if b.is_in_group("player"):
_player_inside = false
bubble.stop())
func _unhandled_input(event: InputEvent) -> void:
if _player_inside and not bubble.is_playing() and event.is_action_pressed("interact"):
bubble.play(lines)