Page 1 of 1

[Solved] Replaying a Node

Posted: Tue Dec 04, 2018 5:37 am
by samcsss
Hello,
My game has 2 languages, with the option to change between them from a settings menu - which calls DialogueSystemController.SetLanguage

When a user changes to a different language mid-conversation, I would like the currently displayed text to be re-shown in the selected language.

What happens at the moment is that the currently displayed text remains in the old language and the new language is used for any subsequent text.

I've been searching for some sort of command or function that will replay or repeat the current node, but so far I've come up empty.

Any guidance is appreciated.

Edit: I just realized what I probably want is to refresh the current subtitle using the localized subtitle, and not replay the whole node (which would likely introduce a bunch of bugs depending on which node was active when the user switched languages)

Re: Replaying a Node

Posted: Tue Dec 04, 2018 9:46 am
by Tony Li
Hi,

This will require a little bit of scripting. You can call the dialogue UI's ShowSubtitle() method, passing it an updated subtitle object that contains the new localized text.

Code: Select all

DialogueManager.SetLanguage(newLanguage);
if (DialogueManager.isConversationActive) {
    var subtitle = DialogueManager.currentConversationState.subtitle;
    subtitle.formattedText = FormattedText.Parse(subtitle.dialogueEntry.currentDialogueText);
    DialogueManager.dialogueUI.ShowSubtitle(subtitle);
}

Re: Replaying a Node

Posted: Tue Dec 04, 2018 5:01 pm
by samcsss
Thanks Tony,

Actually came up with something very similar by modifying the Backtracker script before looking at your reply:

Code: Select all

    
    public class Backtracker : MonoBehaviour
    {
        private ConversationState lastState = null;

        public void OnConversationLine(Subtitle subtitle)
        {
            lastState = DialogueManager.CurrentConversationState;
        }

        // Call this method to go back:
        public void Backtrack(bool toPreviousNPCLine)
        {
            if (lastState == null)// || lastState.subtitle.speakerInfo.IsNPC == false)
                return;

            lastState.subtitle.formattedText = FormattedText.Parse(lastState.subtitle.dialogueEntry.currentDialogueText, 
                DialogueManager.masterDatabase.emphasisSettings);
            DialogueManager.ConversationController.GotoState(lastState);

        }
    }
I guess there's no need to track the current conversation state in a variable if I can pull it form the DialogueManager though.
I'll fool around with whether GotoState is the better option - we might want to replay play the localized audio when changing languages
Thanks for your help!

Re: [Solved] Replaying a Node

Posted: Tue Dec 04, 2018 7:47 pm
by Tony Li
Happy to help!