Copyright © 2025-2026 Candy ArtsNPC Barks
Barks are the short lines NPCs say on their own, outside of conversations: a merchant calling out to passers-by, guards chatting, a villager commenting on the weather. They animate a place without stopping the player.
Candy Dialogue Engine has no separate bark system: barks are ordinary dialogues, run by Engines of their own. This page describes one way to build them. Adapt it to your game.
One Engine per NPC
Assign each NPC that barks its own Engine: a node with Candy_Engine.gd attached, usually a child of the NPC. Since each NPC has its own Engine, several NPCs can bark at the same time, and barks run alongside the main dialogue without disturbing it.
Each bark Engine needs a UI Element to display its lines:
- A bark bubble, above the NPC, in Barks mode. The bark scenes in Scenes/Barks_2D and Scenes/Barks_3D are ready to use: each is an Engine with its bark bubble already configured. Add one to each NPC.
- A shared chat, in Chat mode, like the chat log of an MMO: point every bark Engine's chat_path at the same Chat_Channel, listed as
["path", false]so that none of them owns it (see Chat).
Merchant_Barks
Block "Greeting": "Fresh apples! Come and see!"
Block "Weather": "Looks like rain again..."
Block "Rival": "Don't buy from Hugo, his fish stinks."
To bark, your game picks a Block and starts the dialogue there. Everything dialogues can do is available: Variations for variety, Dispositions and Flags to react to the story, Roles for generic NPCs (see Roles).
Triggering Barks
Barks are started by your game code, with the usual functions (see Running Dialogues). For example, a timer picks a random NPC near the player every few seconds, and starts a random Block on its Engine:
func _on_bark_timer_timeout():
var npc = pick_random_npc_near_player()
if npc == null or npc.bark_engine.dialogue_running:
return
npc.bark_engine.load_scripted_dialogue("Merchant_Barks")
npc.bark_engine.start_dialogue("Barks", npc.bark_blocks.pick_random(), 0)- Turn off input. Turn off the bark Engine's input_enabled, so that the player's advance key doesn't skip barks, or skip the main dialogue and a bark at once. The bark scene templates already have it off.
- Advance automatically. Since the player doesn't advance barks, set auto_advance on the bark Engine so that each line advances by itself. The bark scene templates use 3 seconds.
- Interrupt when needed. Decide which events should cut a bark short (a fight starting, the NPC being talked to, the player leaving the area, a cutscene...), and call interrupt_dialogue() on the bark Engine then (see Interrupting Dialogues).
- Pause during conversations. Stop triggering barks while the main dialogue runs, or suspend the bark Engines, so that NPCs don't talk over it.
- Exclude barks from the history. Turn off the bark Engine's write_dialogue_history if barks shouldn't appear in the Dialogue History (see Dialogue History).
- Preserve the game state. A bark shouldn't switch the game to its dialogue state. Assign bark Engines the engine_mode
"Barks"(the bark scene templates already have it), so that change_game_state() can tell them apart (see Game State). - Preserve the mouse mode. Leave the bark Engine's mouse_mode_start and mouse_mode_end at None.
- Avoid repetition. Record the last Blocks an NPC barked and pick another, or add a cooldown per NPC.
- Mind the cost. Engines that aren't running cost very little, but a crowd barking at once adds up. Limit how many NPCs may bark at the same time.