Saving ConversationState while using simultaneous conversations

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Theocatic
Posts: 2
Joined: Tue Jul 25, 2023 11:00 am

Saving ConversationState while using simultaneous conversations

Post by Theocatic »

I'm currently making a 2d immersive Sim style game, and I'm trying to create a system for passive AI chatter. The idea is for NPCs to have dialogue between themselves in the background, and I need to be able to store their conversation states in case they are interrupted and their conversation needs to be resumed later. The issue is that I can't seem to find anything in the documentation, or forums about how to do this when simultaneous conversations are active. DialogueManager.CurrentConversationState is the only way I see to get a conversation state, and that only grabs the most recently active conversationState.

Is there any way I can get a ConversationState by an ID, or identifier? or alternatively is there any way I can grab the dialogueEntryID from a specific conversation so that I can play the conversation at that node?
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving ConversationState while using simultaneous conversations

Post by Tony Li »

Hi,

When multiple conversations are active, each one will have an ActiveConversationRecord in DialogueManager.instance.activeConversations.

If you stop an NPC's conversation, you can grab its ActiveConversationRecord and record its state. Something like:

Code: Select all

var record = DialogueManager.instance.activeConversations.Find(r => r.actor == npc || r.conversant == npc);
if (record != null)
{
    var currentEntry = record.conversationController.currentState.subtitle.dialogueEntry;
    int conversationID = currentEntry.conversationID;
    int entryID = currentEntry.id;
}
Then save conversationID and entryID, and the actor and conversant if you need to. To resume the conversation:

Code: Select all

var title = DialogueManager.masterDatabase.GetConversation(conversationID).Title;
DialogueManager.StartConversation(title, actor, conversant, entryID);
Theocatic
Posts: 2
Joined: Tue Jul 25, 2023 11:00 am

Re: Saving ConversationState while using simultaneous conversations

Post by Theocatic »

Awesome thanks so much, that should get me in the right direction :)
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving ConversationState while using simultaneous conversations

Post by Tony Li »

Glad to help!
Post Reply