Page 1 of 1
Continue to different nodes programatically based on condition.
Posted: Mon Jul 27, 2020 9:18 pm
by jlhacode
Hi. I have a Success and a Fail node after showing a puzzle. A Success() function gets called if the user succeeds, and vice versa. What would be the best practice way to enter the correct node in each respective method? My continue Continue Button is set to "Always", which might be giving me problems, but I'm not sure.
Re: Continue to different nodes programatically based on condition.
Posted: Mon Jul 27, 2020 9:40 pm
by Tony Li
Hi,
If the puzzle is part of the conversation, such as a riddle, then two links will be helpful:
If the puzzle happens externally from the conversation, and the conversation stays active but waits until the puzzle is done, then you can do something like this:
1. In a dialogue entry node, tell the conversation to wait until it receives a sequencer message. You can choose the message string; it's arbitrary. Maybe something like:
- Sequence:
Code: Select all
SendMessage(Open,,Puzzle); // Call the Open() method on scripts on Puzzle GameObject
WaitForMessage(DoneWithPuzzle) // Stay on this node until message "DoneWithPuzzle"
2. In the Success() function, set a Dialogue System variable and send the sequencer message:
Code: Select all
void Success()
{
DialogueLua.SetVariable("SolvedPuzzle", true);
Sequencer.Message("DoneWithPuzzle");
}
3. In the Failure() function, set a Dialogue System variable and send the sequencer message:
Code: Select all
void Success()
{
DialogueLua.SetVariable("SolvedPuzzle", false);
Sequencer.Message("DoneWithPuzzle");
}
4. Add an empty node after the node above. (See the 'Conversations Evaluate Conditions One Extra Level Ahead' note.) Set the Sequence to "Continue()" to simulate a continue button click and automatically move past the node.
5. Link the empty node to two nodes, each of whose Conditions fields checks the DS variable and goes down the success or failure path.
Re: Continue to different nodes programatically based on condition.
Posted: Mon Jul 27, 2020 10:33 pm
by jlhacode
The solution mostly works, except for one hiccup. The dialogue doesn't progress forward automatically when the puzzle is finished, even after adding a WaitForMessage(Answered) sequence to the node that launches the puzzle. I'm calling Sequencer.Message("Answered"); in the success method.
Re: Continue to different nodes programatically based on condition.
Posted: Mon Jul 27, 2020 10:44 pm
by Tony Li
If you're using continue buttons, change:
to:
Re: Continue to different nodes programatically based on condition.
Posted: Mon Jul 27, 2020 11:20 pm
by jlhacode
Perfect solution, thank you sir!
Re: Continue to different nodes programatically based on condition.
Posted: Tue Jul 28, 2020 9:02 am
by Tony Li
Glad to help!