Switching Conversations at Runtime

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
lunarwood
Posts: 2
Joined: Wed Apr 30, 2025 2:28 am

Switching Conversations at Runtime

Post by lunarwood »

Hi Tony,

Thank you for creating Dialogue System. It's a thoughtful and well-designed plugin!

I've searched through the forums but couldn't find a solution that fits my case. I'm trying to create a dialogue system similar to what you see in games like Story of Seasons or Stardew Valley. I currently have about 20 NPCs, each with multiple types of dialogue: daily, quests, gifting, events, etc. I'm using the naming convention you suggested in another thread (e.g., Daily/npcName) to organize conversations. By default, I assign Daily/npcName to the Dialogue System Trigger component on each NPC's child GameObject.

However, I want to switch the conversation at runtime when the player interacts with an NPC. For example, showing a quest-related conversation if a relevant quest is active. I tried the following logic inside my TalkToNPC() method, which also handles friendship points:

Code: Select all

if (QuestLog.GetQuestState("questName") == QuestState.Active) {
    DialogueManager.StartConversation("Quest/npcName");
}
But this throws the error:
"Dialogue System: Another conversation is already active."

I also tried removing the default conversation from the Dialogue System Trigger. In that case, no dialogue starts at all when the player talks to the NPC.

My goal is:
- If a quest conversation that related to the NPC is activated, show that.
- After the quest dialogue is finished, return to using the daily conversation.
- Keep dialogues in separate assets for easier management, rather than combining them all into one conversation.

Is there a recommended way to dynamically switch conversations via code when the player talks to an NPC? Thank you.
User avatar
Tony Li
Posts: 23251
Joined: Thu Jul 18, 2013 1:27 pm

Re: Switching Conversations at Runtime

Post by Tony Li »

Hi,

I recommend handling the logic inside the conversation(s). Otherwise the logic would be split between C# code and the conversations, making it hard to see the decision-making process in a holistic manner.

Please see the second post in How To: Run a Conversation Only Once. It explains how to start a "hub" conversation (e.g., Daily/npcName) and branch from there to other conversations based on conditions. In most setups, the hub conversation is very small -- just the condition checks -- and links to other conversations using cross-conversation links. (Inspect a node and from "Links To:" select "(Another Conversation)" to create a cross-conversation link.)

Also see How To: Use Group Nodes To Reduce Condition Checking Time.
lunarwood
Posts: 2
Joined: Wed Apr 30, 2025 2:28 am

Re: Switching Conversations at Runtime

Post by lunarwood »

Thank you!!! That worked :) :)

I have another question related to Quests. Is there a way to complete certain quests without requiring the player to talk to an NPC?
For example, I have a quest that asks the player to use the Furnace for the first time. The quest is activated through a conversation with an NPC, but it should be marked complete after the player successfully crafts something using the Furnace without needing to speak to anyone again.

I am not sure but could probably handle this with a script, but I’m wondering if there’s a better or more built-in way to do this within the Quests?
User avatar
Tony Li
Posts: 23251
Joined: Thu Jul 18, 2013 1:27 pm

Re: Switching Conversations at Runtime

Post by Tony Li »

Hi,

Writing a script to handle it is fine. But if you don't want to maintain any scripts, you can use this:

How To: Set Up Quests Without Conversations
Post Reply