How to keep track of previous subtitle text from code

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Jdedueass
Posts: 10
Joined: Wed Aug 18, 2021 3:17 am

How to keep track of previous subtitle text from code

Post by Jdedueass »

Hi!

I'm trying to make a UI panel that displays the previous subtitle text of an active conversation, starting from the second conversation entry, since the first one does not have a previous entry.

From my conversation actor I'm using the function OnConversationLine, and calling a function that updates the UI panel. To clarify, I'm getting the subtitle text using: DialogueManager.CurrentConversationState.subtitle.formattedText.text .

The OnConversationLine function gets called before the conversation line is spoken and it works great, but when the entry node is a player response node, it gets called after the conversation line is spoken, which in my case, causes the desired line to be displayed not being displayed.

E.G. :

Code: Select all

    public void OnConversationLine(Subtitle subtitle)
    {
        UpdateLastResponseShown();
    }

    public void UpdateLastResponseShown()
    {
        if (IsTheFirstEntry)
        {
            lastResponse = DialogueManager.CurrentConversationState.subtitle.formattedText.text;
            lastResponseDisplay.text = "";
        }
        else
        {
            lastResponseText.text = lastResponse;
            lastResponse = DialogueManager.CurrentConversationState.subtitle.formattedText.text;
        }
    }
In short, what's the right way to keep track of the previous subtitle text of an active conversation?
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to keep track of previous subtitle text from code

Post by Tony Li »

Hi,

Are you talking about player response nodes that first appear as response menu buttons?

If so, then if there's only one response button at a time you could untick the Dialogue Manager's Input Settings > Always Force Response Menu. They will play like regular subtitles. Or tick Subtitle Settings > Show PC Subtitles During Line, and untick Skip PC Subtitle After Response Menu.

BTW, you can shorten your code and simply use the subtitle that's passed to OnConversationLine(Subtitle). It's the same subtitle as DialogueManager.currentConversationState.subtitle.
Jdedueass
Posts: 10
Joined: Wed Aug 18, 2021 3:17 am

Re: How to keep track of previous subtitle text from code

Post by Jdedueass »

Thanks for the reply Tony! Indeed that's a cool way to shorten my code.

And yes, I'm talking about the player response node, and unfortunately, I do have multiple response nodes (see attached image).
Attatchent.PNG
Attatchent.PNG (15 KiB) Viewed 387 times
In short, in the game I'm asking questions and I want the player to see the question once he/she needs to answer.

What's the right way to get the highlighted node stored into a variable in code when the conversation is at the response nodes?
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to keep track of previous subtitle text from code

Post by Tony Li »

If you leave the NPC Subtitle Panel's Visibility to anything except 'Only During Content', it will stay visible during the response menu.

However, if that isn't what you need, you can add an OnConversationResponseMenu(Response[]) method and use DialogueManager.currentConversationState.subtitle. This will be the subtitle preceding the response menu.
Jdedueass
Posts: 10
Joined: Wed Aug 18, 2021 3:17 am

Re: How to keep track of previous subtitle text from code

Post by Jdedueass »

Thanks again Tony! Problem solved :D.

I did not take into account the OnConversationResponseMenu function. With that one being used, I figured it out the rest.
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to keep track of previous subtitle text from code

Post by Tony Li »

Great! I'm glad you got it all working now.
Post Reply