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.
Installation
Section titled “Installation”- Download
ss-gameforge-dialoguefrom the releases page. - Copy
addons/ss-gameforge-dialogue/into your project’sres://addons/. - Enable ss-gameforge-dialogue in Project Settings → Plugins.
Core classes
Section titled “Core classes”| Class | Description |
|---|---|
DialogueResource | The lines, who says them, and every timing and animation setting. |
DialogueView | Control that shows and animates a sequence, as a screen box or a speech bubble. |
DialogueView3D | Node3D speech bubble in world space; wraps a DialogueView. |
DialogueSpeaker | A character: name, name colour, portrait and typing voice. |
DialogueTheme | Look of the box: colours, border, texture, font, speaker name and portrait size. |
DialogueHistory | Log of the lines shown, for a backlog screen. |
Quick start
Section titled “Quick start”1. Write the content
Section titled “1. Write the content”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 = falseA literal \n inside a line becomes a real line break.
2. Add the view
Section titled “2. Add the view”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.
3. Play it
Section titled “3. Play 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.
DialogueResource
Section titled “DialogueResource”Properties
Section titled “Properties”| Property | Type | Default | Description |
|---|---|---|---|
dialogues | Array[String] | — | Lines (text or translation keys). BBCode allowed. |
use_translation | bool | true | Pass each line (and speaker names) through tr(). |
speaker | DialogueSpeaker | null | Who says every line, unless line_speakers says otherwise. |
line_speakers | Array[DialogueSpeaker] | [] | Per-line speaker by index. A missing or empty entry uses speaker. |
auto_start | bool | false | Play when the view that holds it in resource is ready. |
allow_skip | bool | true | Let the player complete a line early or advance. |
advance_mode | AdvanceMode | HYBRID | Who moves the dialogue forward (see below). |
text_speed | float | 0.075 | Seconds per character. Lower is faster. |
time_to_start | float | 0.25 | Delay between play() and the box appearing. |
hold_after_line | float | 0.75 | Pause before auto-advancing (AUTO / HYBRID). |
open_time | float | 0.55 | Open animation duration. |
open_transition / open_ease | Tween enums | TRANS_ELASTIC / EASE_OUT | Open animation curve. |
close_time | float | 0.20 | Close animation duration. |
close_transition / close_ease | Tween enums | TRANS_BACK / EASE_IN_OUT | Close animation curve. |
Advance modes
Section titled “Advance modes”| Mode | Behaviour |
|---|---|
AUTO | Advances on its own after hold_after_line. The hold cannot be skipped. |
MANUAL | Waits 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.
DialogueView
Section titled “DialogueView”Properties
Section titled “Properties”| Property | Type | Default | Description |
|---|---|---|---|
resource | DialogueResource | null | Played on ready when its auto_start is on. |
dialogue_theme | DialogueTheme | null | Look of the box. Empty = built-in dark style. |
layout | Layout | SCREEN | SCREEN box or BUBBLE speech bubble. |
input_mode | InputMode | AUTO | Where input is read from. |
skip_action | StringName | ui_accept | Completes the line being typed, or advances. |
back_action | StringName | empty | Shows the previous line again. Empty = off. |
hide_action | StringName | empty | Hides every dialogue while held. Empty = off. |
history | DialogueHistory | own | Where shown lines are recorded. Share one between views. |
voice_bus | StringName | Master | Audio bus for the speakers’ voices. |
Methods
Section titled “Methods”func play(res: DialogueResource) -> void # Start a sequence (ignored while one is running)func stop() -> void # Cancel and play the close animationfunc skip() -> bool # Same as a skip_action pressfunc back() -> bool # Show the previous line againfunc is_playing() -> bool # True from play() until dialogue_finishedfunc get_speaker() -> DialogueSpeaker # Who says the line on screen, or nullfunc apply_theme() -> void # Re-apply dialogue_theme (play() already does)
static func set_all_hidden(hidden: bool) -> void # Hide or show every dialoguestatic func is_all_hidden() -> boolSignals
Section titled “Signals”signal dialogue_started # The open animation startssignal line_changed(index: int) # A new line starts (0-based)signal character_typed(character: String) # Each character as it is revealedsignal dialogue_finished # Once per sequence, after the close animationsignal bubble_resized(size: Vector2) # BUBBLE layout: the bubble changed sizeSafe to call from anywhere
Section titled “Safe to call from anywhere”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_finishedfires once per sequence (not at all whenstop()cancels during the start delay, since nothing opened).- The
skip_actionpress 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.
Layouts: screen box or speech bubble
Section titled “Layouts: screen box or speech bubble”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.
| Layout | Looks like | Fits |
|---|---|---|
SCREEN | A box across the bottom of the view, growing upward. | Top-down and side-view games with a fixed dialogue box. |
BUBBLE | A 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. |
2D speech bubble
Section titled “2D speech bubble”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)3D speech bubble: DialogueView3D
Section titled “3D speech bubble: DialogueView3D”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:
| Property | Default | Description |
|---|---|---|
pixel_size | 0.01 | World units per bubble pixel. |
billboard | true | Always face the camera. |
no_depth_test | true | Draw over geometry, so walls and the speaker’s own mesh never hide the text. |
fixed_size | false | Same size on screen at any distance. |
skip_action, back_action and hide_action are read according to input_mode:
| Mode | Reads 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. |
EVENTS | Only events. |
POLLING | Input.is_action_just_pressed() every frame, in any viewport. The press is not consumed. |
NONE | Nothing: 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()Speakers: name, portrait and voice
Section titled “Speakers: name, portrait and voice”A DialogueSpeaker resource describes who is talking. Make one per character and reuse it.
| Property | Default | Description |
|---|---|---|
display_name | empty | Shown above the text (through tr() when the resource uses translation). Empty = no name. |
name_color | transparent | Colour of the name. Transparent = the theme’s name_color. |
portrait | null | Drawn beside the text at the theme’s portrait_size. Empty = no portrait. |
voice | null | Short sound played while the line types. Empty = silent. |
voice_pitch | 1.0 | Base pitch; higher sounds smaller or younger. |
pitch_variation | 0.05 | Random pitch change per blip (0.05 = ±5%). |
voice_every | 2 | Blip every this many characters (spaces skipped). |
voice_volume_db | 0.0 | Volume 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 = ANAresource.line_speakers = [null, BO] # line 1 is Bo, the rest AnaIt 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).
History and going back
Section titled “History and going back”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 = logEach 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.
Hiding every dialogue
Section titled “Hiding every dialogue”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.
DialogueTheme
Section titled “DialogueTheme”Create via New Resource → DialogueTheme and assign it to dialogue_theme. Without one, a built-in dark style is used.
| Property | Type | Description |
|---|---|---|
background_color | Color | Box fill. With background_texture set, it tints the texture. |
border_color | Color | Box border colour. |
border_width | int | Border width in pixels. |
corner_radius | float | Corner radius. |
padding | Vector2 | Horizontal and vertical padding. |
background_texture | Texture2D | Optional 9-slice texture that replaces the flat box (border and corner settings are then ignored). |
texture_patch_margin | int | Unstretched border of the texture, in pixels. |
font_color | Color | Text colour. |
font_size | int | Font size. |
font | Font | Custom font. Empty = the project’s default. |
name_color | Color | Speaker name colour, unless the speaker sets its own. |
name_font_size | int | Speaker name size. 0 = font_size. |
portrait_size | Vector2 | Size the portrait is drawn at, keeping its aspect. |
position_margin | Vector2 | SCREEN layout: distance from the left, right and bottom edges. |
bubble_max_width | float | BUBBLE 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()BBCode support
Section titled “BBCode support”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.
Translation integration
Section titled “Translation integration”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 = trueThe 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)