Page 1 of 1

Issue Regarding Skipping to an EntryID in a conversation

Posted: Sat Jun 15, 2024 1:49 pm
by czmc14
Hello, I have been using this asset since last week and it completely enhanced my game incredibly. Such an amazing asset it is!
When it comes to my issue, what I am trying to achieve is, when a player leaves a conversation and returns back to the NPC later, I want the conversation to continue from where it is left off.

At the moment, whenever player moves away from the conversation, the conversation ends and I receive the entryID of the dialogue in my script that was present at that moment when the conversation ends

Although, when I go back to the NPC to start another conversation, I couldn't figure out how to start the new conversation from the previous entryID I got from cancelling the previous conversation.

Code: Select all

DialogueManager.StartConversation("CustomerOrder", actor, conversant, dialogueEntryID);
(I retrieve the parameters of the function when the dialogue gets canceled)

I tried to call the above script from Dialogue System Events component(invoking from OnConversationStart), but it still starts the dialogue from the beginning. I know that it is calling the function, because Logs still show that there is no problem accessing the function.

Although if I assign the function that includes the above script to a button press, it works and starts the conversation from the previous entryID successfuly. Is there any way I can make this work when I start the conversation rather than pressing a separate unrelated button? Thanks for help in advance.

Re: Issue Regarding Skipping to an EntryID in a conversation

Posted: Sat Jun 15, 2024 2:36 pm
by Tony Li
Hi,

Are you using a Dialogue System Trigger to start the interaction/conversation?

Is there a message like: "Dialogue System: Not starting conversation. Another conversation is already active" in the Console window when this happens?

If so, then the issue is that the Dialogue System Trigger is starting the conversation from the beginning and then issuing the OnConversationStart event. In this event, your code attempts to start the conversation again at the specified entry ID, but a conversation is already active so it can't start it. (Side node: Technically you can run simultaneous conversations by ticking the Dialogue Manager's Other Settings > Allow Simultaneous Conversations, but that's not what you want to do in this case.)

Instead, use a subclass of DialogueSystemTrigger that remembers the last entry ID and resumes from there:

DialogueSystemTriggerWithResume.cs

Code: Select all

using PixelCrushers.DialogueSystem;
public class DialogueSystemTriggerWithResume : DialogueSystemTrigger
{
    protected virtual void OnConversationLine(Subtitle subtitle)
    {
        if (DialogueManager.currentConversationState.hasAnyResponses)
        {
            // We're not at the end, so record the place where we'd want to resume:
            startConversationEntryID = subtitle.dialogueEntry.id;
        }
        else
        {
            // We're at the end, so record that we'll want to start from the beginning again:
            startConversationEntryID = -1;
        }
    }
}
Use this subclass in place of the original DialogueSystemTrigger component. If you need the save system to remember the last entry ID across scene changes or in saved games, you'll need to save the entry ID, such as storing it in a Dialogue System variable. Example:

DialogueSystemTriggerWithResume.cs

Code: Select all

using PixelCrushers.DialogueSystem;
using UnityEngine;

public class DialogueSystemTriggerWithResume : DialogueSystemTrigger
{
    protected override void DoConversationAction(Transform actor)
    {
        // Check if we've recorded an entry ID in a variable named after the conversation title"
        if (DialogueLua.DoesVariableExist(conversation))
        {
            startConversationEntryID = DialogueLua.GetVariable(conversation).asInt;
        }
        base.DoConversationAction(actor);
    }

    protected virtual void OnConversationLine(Subtitle subtitle)
    {
        if (DialogueManager.currentConversationState.hasAnyResponses)
        {
            startConversationEntryID = subtitle.dialogueEntry.id;
        }
        else
        {
            startConversationEntryID = -1;
        }
        DialogueLua.SetVariable(conversation, startConversationEntryID);
    }
}

Re: Issue Regarding Skipping to an EntryID in a conversation

Posted: Sat Jun 15, 2024 5:03 pm
by czmc14
Wow that was a fast reply, and after a bit of tinkering your solution worked perfectly!

It was giving that "another conversation already active" log as you said, although I wasn't able to see the log because the Debug Level of the Dialogue Manager was set to "Error" only. When I set it to "info" I was able to see it. I was guessing that the problem was related to something like that but wasn't %100 sure before.

Thank you for your help I was stuck in this for a while. Tbh I am still using the Evaluation Version at the moment, but the more I use this asset the more I keep liking it. On top of that, this forum is amazing. I have been spending a lot of time here this week whenever I had to figure out something about the asset. I was able to see how willing you are to help people in here in other posts whenever they have a problem.

Sorry for out of topic rambling but I appreciate the support you give to the people. Seeing the care you have really persuaded me to purchase this asset from the Asset Store.

Take care!

Re: Issue Regarding Skipping to an EntryID in a conversation

Posted: Sat Jun 15, 2024 11:56 pm
by Tony Li
Hi,

Thanks! And glad to help.

Tip: Search for "HOWTO" (one word) plus a question to find useful articles here on the forum.

I recommend keeping the Dialogue Manager's Debug Level set to Warning (not Error) at all times, except for temporarily setting it to Info when you need to get detailed info to trace through something such as the logic decisions made in an active conversation.