"Calling" a dialogue node or another conversation

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
lostmushroom
Posts: 193
Joined: Mon Jul 01, 2019 1:21 pm

"Calling" a dialogue node or another conversation

Post by lostmushroom »

Hey Tony. Is there a way to create some kind of call function to get nodes that need to be used in many conversations? Or to call another conversation instead of linking to it, so that you don't lose your place in the original conversation?

I have a "time of day" variable in my game, so there are several nodes that play whenever a block of time passes: if morning, set to afternoon, if afternoon, set to evening, etc.

Rather than have these nodes in every conversation where time of day can change (there are a lot), I'm wondering if there's a better way to set them up so that they can be called and used wherever required.
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: "Calling" a dialogue node or another conversation

Post by Tony Li »

Hi,

Here are two ideas:

1. Record the state of the current conversation. Then stop it and play the other conversation. When it's done, resume the recorded conversation. Example:

Code: Select all

private ConversationState recordedConversationState = null;

public void Interrupt(string newConversationTitle)
{
    if (DialogueManager.isConversationActive)
    {
        recordedConversationState = DialogueManager.currentConversationState;
        DialogueManager.StopConversation();
    }
    DialogueManager.StartConversation(newConversationTitle);
}

void OnConversationEnd(Transfor actor)
{
    if (recordedConversationState != null)
    {
        var conversation = DialogueManager.masterDatabase.GetConversation(recordedConversationState.subtitle.dialogueEntry.conversationID);
        DialogueManager.StartConversation(conversation.Title, recordedConversationState.subtitle.speakerInfo.transform, recordedConversationState.subtitle.listenerInfo.transform);
        recordedConversationState=  null;
    }
}
2. Or use the ConversationPositionStack. This lets you push the current conversation state onto a stack. Later, you can pop the state off the stack to resume the conversation at that point. Example:

Code: Select all

public void Interrupt(string newConversationTitle)
{
    if (DialogueManager.isConversationActive)
    { // Assumes the Dialogue Manager has a ConversationPositionStack component.
        FindObjectOfType<ConversationPositionStack>().PushConversationPosition();
        DialogueManager.StopConversation();
    }
    DialogueManager.StartConversation(newConversationTitle);
}
Then add PopConversationPosition() to the last node of your interruption conversation.
Post Reply