Specify Starting Entry (and include previous nodes)

Announcements, support questions, and discussion for the Dialogue System.
alexlol
Posts: 35
Joined: Sat Nov 07, 2020 8:20 am

Specify Starting Entry (and include previous nodes)

Post by alexlol »

I've tried searching but couldn't find a specific for this (sorry if I've missed it, please point me in the right direction if so). I have an SMS conversation where I'd like to simulate previous messages history, even though the player has not actually taken part these messages. The idea is they are being dropped into the middle of an SMS thread and, before continuing the conversation, have the opportunity to scroll up and look at what the characters have said to each other in the past.

I thought the 'Specify Starting Entry' option might do the trick, but it only does half of what I'd like to achieve. I'd ideally like to be write the message history out as part of the same conversation, and have those previous nodes be visible when the conversation starts. Can anyone recommend a good way of achieving this? Thanks,

- A
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Specify Starting Entry (and include previous nodes)

Post by Tony Li »

Hi,

If you're using the SMSDialogueUI or Textline project, each conversation saves its history in a dialogue database variable, in a form similar to "3;2;1;2;2;2;3". You could fake the history by manually setting the conversation's variable to a value like that. If you're using SMSDialogueUI or Textline and would like some example code, please let me know.
alexlol
Posts: 35
Joined: Sat Nov 07, 2020 8:20 am

Re: Specify Starting Entry (and include previous nodes)

Post by alexlol »

That sounds great - I am in indeed using SMSDialogueUI, some example code would be very helpful thank you!
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Specify Starting Entry (and include previous nodes)

Post by Tony Li »

Hi,

Here's an example:

DS_PrefilledSMSExample_2021-03-10.unitypackage

It's the Dialogue System's basic DemoScene1, except if you talk to Private Hart the conversation will show in an SMS style UI with everything fast-forwarded to a specified entry in the conversation.

The SMS Dialogue UI and Textline project can resume a conversation and backfill the message history with entries that were previously shown. To do this, they read a variable that was previously set by the OnRecordPersistentData method to contain the history of entries previously shown. To resume the conversation, don't start it using the Dialogue System Trigger's Start Conversation action. Instead, use OnApplyPersistentData.

To set up the scene, I added a script named PrefillSMSConversation (included in the example package) to the scene and specified the conversation and entry ID. This script prefills the conversation history variable with a history up to a specified entry ID. To do this, it follows the first link (even if there are multiple branches) from the START node to the specified entry.

On the SMS Dialogue UI, I ticked Use Conversation Variable.

I configured Private Hart's Dialogue System Trigger to set the "Conversation" variable before starting conversation, and configured it to call the SMS Dialogue UI's OnApplyPersistentData method instead of using the Start Conversation action.
alexlol
Posts: 35
Joined: Sat Nov 07, 2020 8:20 am

Re: Specify Starting Entry (and include previous nodes)

Post by alexlol »

That has worked perfectly, thank you!
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Specify Starting Entry (and include previous nodes)

Post by Tony Li »

Happy to help!
alexlol
Posts: 35
Joined: Sat Nov 07, 2020 8:20 am

Re: Specify Starting Entry (and include previous nodes)

Post by alexlol »

One slightly related question! I don't think this is worth me making a whole new thread for, but I have a small issue as a result of this new feature.

I was initially playing sound events when the NPC bubble was enabled, but this now plays a bunch of one shots at once (because I'm prefilling the conversation). Instead, I created custom Lua event that I can call on dialogue bubbles where I want the sound to be played (ie every bubble that isn't a prefilled one), but the Lua script seems to execute during the 'NPC Delay Icon' popup as opposed to the actual popup of the NPC text itself.

My initial thinking is to just make the Lua event into a coroutine that waits for the NPC delay, but that seems prone to difficulties if I change the delay down the line. Does Dialogue System offer a better way around this I'm not seeing?
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Specify Starting Entry (and include previous nodes)

Post by Tony Li »

Hi,

For a no-script way, what if you play the sounds events as sequences? If you don't want to configure every node individually, you can set the Dialogue Manager's Camera & Cutscene Settings > Default Sequence to something like:

Code: Select all

Audio(incomingMessage)
If you don't want to play the sound for the player's messages, set Default Player Sequence to:

Code: Select all

None()
alexlol
Posts: 35
Joined: Sat Nov 07, 2020 8:20 am

Re: Specify Starting Entry (and include previous nodes)

Post by alexlol »

Good idea, thanks! I just tested this and it does seem to still play when the Pre Delay Icon becomes active, rather than the dialogue bubble itself. Is there a way to delay the audio message, or some other way to ensure it plays at the correct time?
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Specify Starting Entry (and include previous nodes)

Post by Tony Li »

Hi,

The SMSDialogueUI and TextlineDialogueUI send the sequencer message "Received" after an NPC subtitle has completed the pre delay period. You can tell the Audio() command to wait for this message:

Code: Select all

Audio(incomingMessage)@Message(Received)
Post Reply