Gridwright Store

6 Dec 2026 · By Gridwright Studio

Typewriter Dialogue Text in Godot 4 With Skip and Talking Portraits

Gridwright pack artwork for Typewriter Dialogue Text in Godot 4 With Skip and Talking Portraits

Dialogue that types out letter by letter takes ten minutes to start in Godot 4. Then the details show up: a word jumps to the next line halfway through, the skip key throws away a line nobody read, and the blips play more than twice as often at 144 fps as at 60.

Every line of code below was run in Godot 4.7.2 at fixed frame rates, with the Farmer's portrait from our Farm RPG, Gridwright Story from Pixel Fonts 2 at 13 px and a blip from Retro Sound Effects. For drawing the faces, see dialogue portraits: expressions, sizes and layout.

visible_characters and visible_ratio

Label and RichTextLabel both have visible_characters, how many characters are drawn (-1 means all), and visible_ratio, the same thing as a fraction. On a 25-character line, a ratio of 0.5 showed 12 characters, and 1.0 set visible_characters to -1. What counts, measured on a RichTextLabel with BBCode on:

  • BBCode tags don't. "[color=yellow]Mia[/color]: Hello there, [b]farmer[/b]!" is 54 characters of text, and get_total_character_count() returned 25.
  • [wave] and [shake] count nothing, and an inline image counts as one.
  • New text doesn't reset the count. After 5 characters of one line, the next line also showed 5, so set visible_characters to 0 with every new text.

Why words jump to the next line

Both nodes have visible_characters_behavior, and both start on Characters Before Shaping. On a Label that lays out only the visible text, so a word typed at the end of a line sits there until it no longer fits, then jumps down. In a 150 px Label, a 79-character line grew from 1 line to 4 as it typed, and "down", "water" and "gets" each started on one line and finished on the next. One line fixes it:

  • text_label.visible_characters_behavior = TextServer.VC_CHARS_AFTER_SHAPING

With Characters After Shaping the Label had all 4 lines from the first letter, and nothing moved. A RichTextLabel kept the full layout in both settings, and it reads BBCode, so it is the node for dialogue.

A typewriter that keeps time

The box is a Control named DialogueBox with four children: Text (a RichTextLabel with BBCode on), Portrait (an AnimatedSprite2D), NextArrow and Blip (an AudioStreamPlayer). Here is its whole script, one item per line:

  • extends Control
  • const PAUSES := {",": 0.15, ".": 0.3, "!": 0.3, "?": 0.3}
  • @export var chars_per_second := 30.0
  • @export var blip_every := 3
  • @onready var text_label: RichTextLabel = $Text
  • @onready var portrait: AnimatedSprite2D = $Portrait
  • @onready var next_arrow: CanvasItem = $NextArrow
  • @onready var blip: AudioStreamPlayer = $Blip
  • var lines: PackedStringArray = []
  • var index := 0
  • var parsed := ""
  • var wait := 0.0
  • var letters := 0
  • var typing := false
  • func start(new_lines: PackedStringArray) -> void: lines = new_lines; index = 0; show(); show_line()
  • func show_line() -> void: text_label.text = lines[index]; text_label.visible_characters = 0; parsed = text_label.get_parsed_text(); wait = 0.0; letters = 0; typing = true; next_arrow.hide(); portrait.play("talk")
  • func _process(delta: float) -> void: wait -= delta; while typing and wait <= 0.0: reveal()
  • func reveal() -> void: text_label.visible_characters += 1; on_char(parsed[text_label.visible_characters - 1]); if text_label.visible_characters >= parsed.length(): finish_line()
  • func on_char(c: String) -> void: wait += 1.0 / chars_per_second + PAUSES.get(c, 0.0); portrait.play("still" if PAUSES.has(c) else "talk"); if c != " " and not PAUSES.has(c): count_letter()
  • func count_letter() -> void: letters -= 1; if letters <= 0: letters = blip_every; blip.play()
  • func finish_line() -> void: typing = false; text_label.visible_characters = -1; next_arrow.show(); portrait.play("still")
  • func _unhandled_input(event: InputEvent) -> void: if visible and event.is_action_pressed("ui_accept"): get_viewport().set_input_as_handled(); press()
  • func press() -> void: (finish_line if typing else next_line).call()
  • func next_line() -> void: index += 1; (show_line if index < lines.size() else hide).call()

wait is the time until the next character. _process takes each frame's time off it and reveals characters while time is owed, and each character adds 1/30 s at 30 a second, plus a pause after punctuation. So the speed doesn't follow the frame rate: our 45-character first line took 1.76 to 1.77 s at 30, 60 and 144 fps. parsed is the text without tags, so its indexes match visible_characters.

The Tween version and its skip trap

A line with no pauses can use a Tween instead. We tested these lines in a script that extends the box, with _process left empty:

  • var tween: Tween
  • func type_with_tween() -> void: text_label.visible_ratio = 0.0; typing = true; next_arrow.hide(); tween = create_tween(); tween.tween_property(text_label, "visible_ratio", 1.0, text_label.get_total_character_count() / chars_per_second); tween.tween_callback(finish_line)
  • func skip_tween() -> void: tween.kill(); finish_line()

The characters came evenly, and the callback ran after 1.5 s. The trap is the skip. Set only visible_ratio to 1.0 and the next frame showed 5 characters again, with the callback still running later. Kill the tween first. A killed tween never runs its callback, so skip_tween() calls finish_line() itself.

Skip on the first press, next line on the second

press() makes one choice per press. A press 8 characters into a line showed the whole line, the arrow and the still face, and the next press went on. Three more things we measured:

  • Two ifs, if typing: finish_line() and then if not typing: next_line(), let one press finish a line and leave it, so line 1 was never seen whole.
  • Without set_input_as_handled(), another node listening for ui_accept got both presses. With it, none.
  • is_action_pressed() ignores the echo events a held key sends, so holding Enter doesn't race through the talk.

The next arrow and the talking portrait

NextArrow is shown only in finish_line(), which the last character and the skip both call: it stayed hidden for all 106 typing frames at 60 fps. It can be any CanvasItem, such as an AnimatedSprite2D that bobs. Farm RPG's Update 34 has one, 4 frames at 150 ms, with a 9-slice wood frame, a name plate, a choice cursor and a 72x72 portrait frame whose window takes the 64x64 portraits at (4, 4).

Portrait has two animations: talk, the two talk frames looping at 8 fps, and still. on_char() plays still on punctuation, so the mouth closes for the pause, 21 frames after "Morning!". Calling play("talk") on every letter didn't restart the loop, and both talk frames kept showing. Farm RPG's portraits cover all 35 ready characters in 8 expressions, each with a still, a blink and two talk frames.

A blip every few letters

count_letter() counts letters, never spaces or punctuation, and blips on the first letter and every blip_every after it. Our line has 36 letters and played 12 blips at 30 and 90 characters a second, at 30, 60 and 144 fps alike.

The common shortcut, checking visible_characters % 3 == 0 every frame, played 14, 28 and 67 blips at 30, 60 and 144 fps (30 characters a second), because the count sits still for several frames. Retro Sound Effects has eight blip voices (tiny, pip, mid, deep, robot, gruff, ghost and chirp), so each character can sound different. The mid one we used is 0.04 s long.

Fonts and the box

Gridwright Story is a serif text font for dialogue, crisp at its native 13 px and whole multiples of it. Pixel Fonts 2 also has Gridwright Narrow for long lines in small boxes, both with Western European accents.

An RPG dialogue box, quest log and item card set in the Gridwright Pixel Fonts 2 fonts, with accented names
Pixel Fonts 2 in a dialogue box, a quest log and an item card, accents included (panels sold separately).

Pixel VN UI has a dialogue box with a name plate and a 4-frame click-to-continue arrow in four themes. It is made for Ren'Py, and every piece also comes as a PNG at 1x to 4x, with a pieces.json of 9-slice insets and text padding for Godot.

The Pixel VN UI dialogue box in its four themes, Storybook, Neon, Sakura and Gothic, each with a name plate
Pixel VN UI: the same dialogue box in all four themes.

Checklist

  • A RichTextLabel, or a Label on Characters After Shaping.
  • visible_characters = 0 with every new text.
  • A countdown for time, so the speed ignores the frame rate.
  • One press, one choice, and kill a Tween before you skip it.
  • The arrow and the still face only when the line is done, and blips counted per letter.

Farm RPG, Pixel Fonts 2, Pixel VN UI and Retro Sound Effects are all in the $20 bundle shown on this page, with every other Gridwright pack and tool.

Gridwright packs can be used in commercial games; you may not resell the files themselves. Farm RPG asks for a credit, “Art by Gridwright” with a link; the other three don't require one. More in can I use game assets in a commercial game.

If your game needs its own cast of portraits or a dialogue box in its style, you can order a custom pack.

Found it useful? Share it

Get the art for your game

Our packs together in the $20 Megabundle, a custom pack drawn for your game, or the packs in this post from $9.99 each.

Best value

Gridwright Megabundle

Our packs and tools on itch.io in one bundle, for less than three of them one by one.

Get it for $20 (opens in a new tab)

Custom packs from $49

Not finding it? We draw it for your game, in 14 days or your money back.

Order a custom pack

Packs mentioned

Related guides