Speech Bubbles
Speech bubbles display Lines in comic-style bubbles, in the game world. There are two kinds:
Both exist in 2D and 3D versions, and behave the same way.
- Scripts: Speech_Bubble_2D.gd, Speech_Bubble_3D.gd, Bark_Bubble_2D.gd, Bark_Bubble_3D.gd (in Scripts/Actor_Nodes)
- Templates: Scenes/Speech_Bubbles_2D, Scenes/Speech_Bubbles_3D, Scenes/Barks_2D, Scenes/Barks_3D
- Updates: the scripts are 'unsafe', and so is every template except Default.tscn (see Customizing UI Elements, on the UI page)
- Settings: see Bubbles Mode and Barks Mode
Note: The Godot Editor may print this error when it loads a scene containing a speech bubble or a bark bubble: Path to node is invalid: 'SubViewport'. (or 'BarkBubble/SubViewport' for a bark scene).
It's caused by the Godot editor loading the speech/bark bubbles ViewportTextures before Subviewports.
Everything works correctly: you can ignore it. |
Nodes
| Variable | Node |
| label | Required. RichTextLabel: the spoken text, inside the SubViewport. |
| viewport | Required. The SubViewport the text is drawn in. |
| sprite | Required. A Sprite2D (2D) or Sprite3D (3D) displaying the SubViewport's texture: this is the bubble the player sees. |
| voice_node | The voice player for this bubble: an AudioStreamPlayer2D or AudioStreamPlayer3D, so the voice is emitted from the bubble's position (see Voice Players). Left empty, the bubble plays no voice, and reports it when the game starts. |
How a bubble is drawn
The text is written in the SubViewport, and the sprite displays it. For each Line, the bubble resizes the label to its text (up to max_width, plus text_width_margin on the sides), resizes the SubViewport to match, then places itself with x_offset and y_offset (and z_offset in 3D).
To change the bubble's look, style the label (the templates assign it a StyleBoxTexture background), and turn on the SubViewport's transparent_bg so only the label is displayed.
Lexicon clicks
Since the text is drawn through a SubViewport, Lexicon keywords can't be clicked in the template bubbles.
Placing Speech Bubbles
On Actors (Bubbles mode)
Instantiate a speech bubble scene as a child of the Actor's node, and list it as "Speech_Bubble" in an internal_node_dict dictionary on that node's script:
@onready var internal_node_dict = {
"Speech_Bubble": $SpeechBubble,
}
The same dictionary can list other nodes of the Actor, for the Cutscene commands. How the Engine locates the Actor's node is explained in Bubbles Mode.
On VN busts (VN Bubbles mode)
Instantiate a speech bubble scene as a child of each bust node of the VN Scene, with the name set in the VN Scene's speech_bubbles_name (default SpeechBubble). See VN Scenes.
Bark bubbles (Barks mode)
A bark scene is a small Engine of its own, with its bark bubble at barks_path in its ui_elements_paths. Add one to each NPC that barks. See Barks Mode.
Hook Functions
x_write_begun(), x_write_progress(), x_write_finished() and x_speech_advance(), called on the bubble: see Speech Display.