How to dynamically add new lines to resumed conversation in Lobby example

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
xuoot
Posts: 19
Joined: Wed Jul 29, 2020 3:01 am

How to dynamically add new lines to resumed conversation in Lobby example

Post by xuoot »

Hi!

I was wondering if it was possible to create new Conversations within the Lobby example or somehow make it possible to recognize that a player just entered the scene. I want it so that whenever the player returns to talk to someone (ex. Adam), Adam will say some variation of "Oh you're back!" or "Welcome back!" and then resume where he left off in the last conversation. Is there a way to add that extra line in front of any resumed conversation?

I was thinking I could create a variable to store the "Oh you're back!" or "Welcome back!" line and use the variable value in the script. I just wasn't sure how to hook up lines like these to preface a conversation in progress. Thanks!
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to dynamically add new lines to resumed conversation in Lobby example

Post by Tony Li »

Hi,

You can manually tell the dialogue UI to play a subtitle. Rough example:

Code: Select all

// Assumes the conversation has already started:
var subtitle = new Subtitle(
    DialogueManager.conversationModel.conversantInfo, // (NPC is speaking)
    DialogueManager.conversationModel.actorInfo, // (player is receiving)
    FormattedText.Parse("Welcome back!"), 
    string.Empty, // (use default sequence)
    string.Empty, // (no response menu sequence)
    null); // (no dialogue entry)
DialogueManager.dialogueUI.ShowSubtitle(subtitle);
Note: I haven't tested the code above. It may have typos, etc.

If you need more details, let me know.
xuoot
Posts: 19
Joined: Wed Jul 29, 2020 3:01 am

Re: How to dynamically add new lines to resumed conversation in Lobby example

Post by xuoot »

Thanks Tony! It works when I add a new DialogueEntry to the subtitle object. However, there seems to be issues when I resume the conversation and the game loads from save. I believe the subtitle need a DialogueEntry in order to be properly re-created when the conversation resumes. I wasn't sure how to create that DialogueEntry with the correct ID or correct outgoing links.

Is there a way to either remove this conversation from the saved set of messages (mark it as not saved) or to allow it to be saved with a valid DialogueEntry? Thanks!
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to dynamically add new lines to resumed conversation in Lobby example

Post by Tony Li »

Hi,

Create a new dialogue entry for the "Welcome back!" line. You don't have to connect it to anything. It can just sit on the side of your conversation canvas without any incoming or outgoing links.

When you create the Subtitle object, specify this dialogue entry instead of null. You can get it from the database by ID:

Code: Select all

var dialogueEntry = DialogueManager.masterDatabase.GetDialogueEntry(conversationID, dialogueEntryID);
You could also get it by Title or Dialogue Text, but you'd have to search the conversation's dialogueEntries list to find it. Example:

Code: Select all

var conversation = DialogueManager.masterDatabase.GetConversation("Conversation Title Here");
var dialogueEntry = conversation.dialogueEntries.Find(entry => entry.DialogueText == "Welcome back!");
xuoot
Posts: 19
Joined: Wed Jul 29, 2020 3:01 am

Re: How to dynamically add new lines to resumed conversation in Lobby example

Post by xuoot »

Thanks so much Tony that worked!
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to dynamically add new lines to resumed conversation in Lobby example

Post by Tony Li »

Glad to help!
Post Reply