Page 1 of 1

Suspend a conversation until variable has a certain value

Posted: Fri Nov 06, 2020 2:04 pm
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 207 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 207 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?

Re: Suspend a conversation until variable has a certain value

Posted: Fri Nov 06, 2020 2:35 pm
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.

Re: Suspend a conversation until variable has a certain value

Posted: Fri Nov 06, 2020 4:54 pm
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 197 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.

Re: Suspend a conversation until variable has a certain value

Posted: Fri Nov 06, 2020 5:04 pm
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".

Re: Suspend a conversation until variable has a certain value

Posted: Fri Nov 06, 2020 7:01 pm
by purexlove
It worked, cheers 8-)

Re: Suspend a conversation until variable has a certain value

Posted: Fri Nov 06, 2020 8:36 pm
by Tony Li
Glad to help!