Page 1 of 2

Make a conversation advance based on the status of a second one

Posted: Wed Mar 02, 2022 7:48 am
by Error412
Hi, I have 2 conversations running at the same time and always active.
I would like the two to interact, for example the 1st to stop until further progress has been made within the 2nd one.
I tried to use a variable, set by a node in the 2nd conversation and then checked by the 1st conversation which works quite well.
Unfortunately if the 1st conversation have reached the node where the variable is tested, before being set by the 2nd, the conversation get stuck as the test in executed only once.
I tried then sending a sequence message which have the opposite downside: it works perfectly if the user reach the node before triggering the SendMessage, but it's useless if the user haven't yet reached it as the message is sent only once.

I tried to solve this by creating double path: the message in conversation 2 both set a variable and send a message. Within the 1st conversation I first check for the variable. If true I move forward, if false I move to a different node that waits for the message.

I have two questions:
- Does my solution makes sense or did I create something convoluted that actually can be solved in a simpler way? :?
- If the above is optimal then I need help to understand why sending a message from one dialogue to another doesn't seem to work. I used the following syntax and none of them did work:
SendMessage(MyMessage,)
SendMessage(MyMessage, ,everyone)
SendMessage(MyMessage, ,everyone,broadcast)

Just for testing I tried to send the same message through a click on an unrelated object using a Playmaker action (SendSequencerMessage.cs) and it works perfectly somehow.

Re: Make a conversation advance based on the status of a second one

Posted: Wed Mar 02, 2022 10:38 am
by Tony Li
Hi,

I think sequences, rather than variables, are the approach to take with this.

Scripting
If you're comfortable with a little scripting, you can write two custom sequencer commands -- for example, called something like SendSignal() and WaitForSignal(). The idea is that they'd work like WaitForMessage() except it can remember if a signal has already been sent before the conversation gets to WaitForSignal().

Conversation 1 can use WaitForSignal() to wait for a signal to be set, finishing instantly if the signal has already been set.

Conversation 2 can use SendSignal() to set the signal.

This will cover both scenarios:

Scenario 1: Conversation 1 gets to WaitForSignal() before conversation 2. Then conversation 2 uses SendSignal(), at which point conversation 1 continues.

Scenario 2: Conversation 2 uses SendSignal() before conversation 1 gets to the waiting node. When conversation 1 gets to the waiting node, WaitForSignal() sees that the signal has been set, so it continues.


Non-Scripting
If you're not comfortable with scripting, let me know. We can come up with a similar solution using PlayMaker, or it might just be easier if I were to provide the code for those two sequencer commands.

Re: Make a conversation advance based on the status of a second one

Posted: Wed Mar 02, 2022 11:48 am
by Error412
Hi Tony, your suggestion makes sense but I'm not comfortable scripting, this is why I rather use Playmaker whenever possible.
If you can provide the script that would work, but I don't want to waste your time. Any idea why if I send a sequence message from one conversation it doesn't get received by the other? Perhaps if I can solve that I can just use my weird hack above :D

Re: Make a conversation advance based on the status of a second one

Posted: Wed Mar 02, 2022 3:45 pm
by Tony Li
Hi,

I think it's cleaner to use a custom sequencer command. This example scene:

DS_SignalExample_2022-03-02.unitypackage

contains two sequencer commands:
  • SendSignal(signal): Sends a signal (any arbitrary string).
  • WaitForSignal(signal): Waits for a signal, or succeeds immediately if a signal has been sent before this command runs. When this command is done, it clears the signal.

Re: Make a conversation advance based on the status of a second one

Posted: Thu Mar 03, 2022 6:11 am
by Error412
Thanks Tony, this works very well!
There is just one issue, which you can reproduce if you set for conversation 1 the SMS UI: the message for "waiting signal" and "signal received" get both displayed at the same time (if the signal was already sent when the node is reached).

ps. this will probably display my ignorance but how do this scripts work without being assigned to anything? Does Unity just search all .cs files in the project? :?

ps2. is there any easy way to send this signal from within Playmaker? In case I want to do the same but due to interactions outside dialogues.

Re: Make a conversation advance based on the status of a second one

Posted: Thu Mar 03, 2022 8:02 am
by Tony Li
Hi,
Error412 wrote: Thu Mar 03, 2022 6:11 amThere is just one issue, which you can reproduce if you set for conversation 1 the SMS UI: the message for "waiting signal" and "signal received" get both displayed at the same time (if the signal was already sent when the node is reached).
Isn't that what you would want to happen? What should happen instead?
Error412 wrote: Thu Mar 03, 2022 6:11 amps. this will probably display my ignorance but how do this scripts work without being assigned to anything? Does Unity just search all .cs files in the project? :?
Essentially yes. Unity compiles all .cs files into libraries (DLL files). C# code can then check these libraries for the existence of scripts such as the new sequencer commands.
Error412 wrote: Thu Mar 03, 2022 6:11 amps2. is there any easy way to send this signal from within Playmaker? In case I want to do the same but due to interactions outside dialogues.
Use a Play Sequence action.

Re: Make a conversation advance based on the status of a second one

Posted: Fri Mar 04, 2022 3:22 am
by Error412
Hi Tony,
Tony Li wrote: Thu Mar 03, 2022 8:02 am Isn't that what you would want to happen? What should happen instead?
Ideally the "waiting for signal" message is displayed only when actually waiting for signal, if (when the node is reached) the signal has already been sent the dialogue skips to the next node instead. To me your example seems to work like this, which would be perfect, but when switching to the SMS UI both messages are displayed when the signal has already been sent before.
Please note this is not pivotal, your helped already greatly and I can find a workaround so you don't have to find a solution. I was just curious to understand if it was something simple to solve :)
Tony Li wrote: Thu Mar 03, 2022 8:02 am Essentially yes. Unity compiles all .cs files into libraries (DLL files). C# code can then check these libraries for the existence of scripts such as the new sequencer commands.
Thanks this makes sense now!
Tony Li wrote: Thu Mar 03, 2022 8:02 am Use a Play Sequence action.
I'm an idiot, of course, thanks Tony.

Re: Make a conversation advance based on the status of a second one

Posted: Fri Mar 04, 2022 8:51 am
by Tony Li
I think the issue with the SMS UI is that it keeps a log of all subtitle texts. You may need to handle it specially somehow. Perhaps you can give that node no text.

Re: Make a conversation advance based on the status of a second one

Posted: Sat Mar 05, 2022 2:30 am
by Error412
I'll give it a go, thank you!

Re: Make a conversation advance based on the status of a second one

Posted: Tue Apr 19, 2022 8:30 am
by Error412
Tony Li wrote: Thu Mar 03, 2022 8:02 am Use a Play Sequence action.

Hi Tony, it has been a while, I hope you are well.
I just tried this suggestion and it didn't work for me.
I have a node with a sequence set as "WaitForSignal(Test)" and within Playmaker a Start Sequence action with the sequence field as "SendSignal(Test)". I also tried to add the object contain the conversation trigger in the speaker field and check "inform partecipants" but with no result.