Page 1 of 1

Saving ConversationState while using simultaneous conversations

Posted: Tue Jul 25, 2023 11:10 am
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?

Re: Saving ConversationState while using simultaneous conversations

Posted: Tue Jul 25, 2023 11:45 am
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);

Re: Saving ConversationState while using simultaneous conversations

Posted: Tue Jul 25, 2023 12:10 pm
by Theocatic
Awesome thanks so much, that should get me in the right direction :)

Re: Saving ConversationState while using simultaneous conversations

Posted: Tue Jul 25, 2023 2:29 pm
by Tony Li
Glad to help!