Multiple Asychronous Messaging

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Multiple Asychronous Messaging

Post by eeeli »

Hello!

You helped me a little while back setting up a custom SMS Dialogue UI which I was very grateful for, and I'm back with a new question.

I was wondering if you could help me with a basic setup for handling multiple asynchronous conversations happening at a delay. I'm looking to model the behavior of a texting on a phone, where you can be texting multiple people at once, the responses are on a delay. Between delays you can enter/exit other conversations, or go off and do something entirely different. But when the delay on a response is up, the player's phone will receive a prompt that will place them back into that particular conversation.

So I think the main behaviors I'm looking for are:
1. Having a setup where the dialogue system is keeping track of various conversations with responses from NPCs on delays from anywhere between a couple seconds and a couple minutes.
2. Knowing when a response from an NPC is ready, so I can call the prompt which will guide them back to that conversation.

Thanks so much in advance for any guidance you have in setting up a template that handles this :)
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Multiple Asychronous Messaging

Post by Tony Li »

Hi,

That's a bit more complex. It may require some custom scripting on your part.

Here's one way to approach it:

You could run all of the conversations in parallel, in separate dialogue UIs.

To run more than one conversation at a time, tick the Dialogue Manager GameObject's Other Settings > Allow Simultaneous Conversations checkbox.

Create a GameObject for each person.

To each person GameObject, add a child GameObject with a Canvas. Add the person's dialogue UI in the Canvas.

On the person GameObject, add a Dialogue Actor component so you can associate the GameObject with an actor in the dialogue database. Add an Override Dialogue UI component, and assign the person's dialogue UI.

Here's where you'll need to do some custom scripting:
  • Keep each person's Canvas disabled so it's not visible. When the player choose a person to talk to, enable that person's Canvas. When the player leaves the conversation, disable the Canvas.
  • Add an OnConversationLine method to each person GameObject. In this method, check if the person's Canvas is disabled. If it's disabled, show a prompt to let the player know the conversation just "received" a message.
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Re: Multiple Asychronous Messaging

Post by eeeli »

Thank you so much!

I set it up just like you suggested, and it's working more or less just as I wanted it to, there's just some bugs I'm still ironing out.

I was wondering if you had a suggestion for a way to circumvent any of the conversations ever ending. Right now, when you make it to the end of a text chain the Dialogue UI closes itself because it assumes it's done with the conversation (which normally it would be). But instead, I'd like it to behave almost as if the conversation never ends, it just hangs there on the final response, so the player can scroll back through any of their text conversations. Thanks again for all your help!
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Multiple Asychronous Messaging

Post by Tony Li »

Hi,

Set the last node's Sequence to:

Code: Select all

WaitForMessage(Forever)
WaitForMessage() waits until the sequencer receives an arbitrarily specified message string. As long as you don't ever send the string "Forever", it will wait forever.
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Re: Multiple Asychronous Messaging

Post by eeeli »

Hi,

Sorry to resurrect this thread, but I've run into a little bit of trouble with my setup.

I recently moved the Response Menu to a different canvas - the setup being that there's an in-world canvas that shows the text messages (subtitles), and a another canvas that shows what you can text (responses).

When I enter the conversation for the first time everything is okay. However, when I exit the conversation, and then reenter it, the response menu doesn't reappear. The canvas that the response menu is on has been disabled, and then is re-enabled when I reopen the text screen.

Now there are times that the player doesn't have a response, like if an NPC is in the middle of sending multiple messages, but when I re-open the menu and the player should have a response, the response menu never pops back up, despite the canvas being re-enabled. I'm thinking I probably have to let my CustomSMSDialogueUI know that there's an active response, or at least have it check for one when it reopens, but I'm not sure what exactly I should be calling/checking there.

Thanks so much for any help :)
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Multiple Asychronous Messaging

Post by Tony Li »

Hi,

Are you disabling the canvas by disabling the Canvas component or by deactivating its GameObject? If you're deactivating the GameObject, try disabling the canvas instead. When you deactivate and reactivate a GameObject, it triggers OnDisable() and OnEnable() on all the components in its hierarchy. This can have effects such as resetting the Animators.

If that doesn't help, can you send a reproduction project to tony (at) pixelcrushers.com?
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Re: Multiple Asychronous Messaging

Post by eeeli »

Ahhh! Thank you, yup that was it. I forgot I had to enable/disable the canvas specifically, not just the gameobject.

Unfortunately I'm running into one more issue, the Response Menu sees input regardless of whether the canvas is disabled, so now once I've opened the text message screen once and then leave it, I'm confirming responses to dialogue I can no longer see.

Is there a way I can override the response input to make it only give input when the canvas is enabled?
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Multiple Asychronous Messaging

Post by Tony Li »

Hi,

Add a Canvas Group component to the Canvas. When you disable the Canvas, also set the Canvas Group's interactable property false. When you enable the Canvas, set interactable true.
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Re: Multiple Asychronous Messaging

Post by eeeli »

Thank you! The canvas group solved it :)
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Multiple Asychronous Messaging

Post by Tony Li »

Great! Glad to help.
Post Reply