Suspend a conversation until variable has a certain value

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
purexlove
Posts: 5
Joined: Fri Nov 06, 2020 1:40 pm

Suspend a conversation until variable has a certain value

Post by purexlove »

Hello,

In my game I have kind of tutorial in which NPC talks to Player. During tutorial there are few gameplay objectives that player needs to complete in order to proceed with the tutorial (conversation with NPC). So my goal is to make a simple sequence: Listen to NPC -> Dialogue UI is hidden -> Player completes objective -> Dialogue with NPC resumed and new cycle starts -> ....

To track player progress I made a variable inside DialogueManager:
Screenshot 2020-11-06 204658.png
Screenshot 2020-11-06 204658.png (3.96 KiB) Viewed 209 times
Then, after player completes the task, I'm setting gameplayProgress variable value from code:

Code: Select all

DialogueLua.SetVariable("gameplayProgress", objectiveIndex);
And finally, I'm setting gameplayProgress check in Conditions for dialogue entry which should appear only after Player completes an objective, and gameplayerProgress is set to 1 or higher.
Screenshot 2020-11-06 205239.png
Screenshot 2020-11-06 205239.png (91.92 KiB) Viewed 209 times
But when dialogue reaches Dialogue Entry with unsatisfied condition Dialogue is simply terminated. What I wanted instead, is temporary hide dialogue UI until variable in Conditions is changed. Am I doing it right, or there is another proper way to implement what I want?
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Suspend a conversation until variable has a certain value

Post by Tony Li »

Hi,

When conversations evaluate conditions, they act on them immediately (i.e., if none of the conditions are true, the conversation ends).

Instead, see this new post which explains how to use WaitForMessage() to suspend a conversation until a certain event occurs.
purexlove
Posts: 5
Joined: Fri Nov 06, 2020 1:40 pm

Re: Suspend a conversation until variable has a certain value

Post by purexlove »

For some reason it's not working for me. I added WaitForMessage sequence:
Screenshot 2020-11-06 235200.png
Screenshot 2020-11-06 235200.png (64.08 KiB) Viewed 199 times
And sending a message with a hotkey:

Code: Select all

private void Update()
    {
        if (Input.GetKeyDown(KeyCode.M))
            Sequencer.Message("mes");
    }
   
But dialogue is not proceeding forward, although it's possible to manually click on 'continue' button and proceed.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Suspend a conversation until variable has a certain value

Post by Tony Li »

If you're requiring continue button clicks, then change the Sequence to:

Code: Select all

Continue()@Message(mes)
This will simulate a continue button click when it receives the message "mes".
purexlove
Posts: 5
Joined: Fri Nov 06, 2020 1:40 pm

Re: Suspend a conversation until variable has a certain value

Post by purexlove »

It worked, cheers 8-)
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Suspend a conversation until variable has a certain value

Post by Tony Li »

Glad to help!
Post Reply