Jump to Node from Anywhere in Conversation

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
drod7425
Posts: 11
Joined: Thu Jan 15, 2015 8:59 am

Jump to Node from Anywhere in Conversation

Post by drod7425 »

Hello,

I've looked through the forum for this question and I found one that was similar:

viewtopic.php?f=3&t=358&p=1609&hilit=node#p1609

But my case is different as I want to start the conversation on the same start node every time. How would I jump to a specific node once I am in the conversation?

My use case:

Client wants huge conversation. Huge conversation needs shortcuts to these 10 root nodes within the conversation. I'm writing a sequencer command called RegisterShortcut(title,id). RegisterShortcut will generate a shortcut ui button that, when clicked, will jump to the node id. But I don't know how to manually override the conversation to jump to that node.

Thanks,
Dave
User avatar
Tony Li
Posts: 21026
Joined: Thu Jul 18, 2013 1:27 pm

Re: Jump to Node from Anywhere in Conversation

Post by Tony Li »

Hi Dave,

Instead of using "magic number" IDs, why not create 10 nodes off of the START node, and put Conditions on each one. For example:

1. On the Variables tab, define a variable named "Topic".

2. Set up your conversation like this:
  • START
    • "Topic 1" { Conditions: Variable["Topic"]==1 }
    • "Topic 2" { Conditions: Variable["Topic"]==2 }
    • "Topic 3" { Conditions: Variable["Topic"]==3 }
    • ...
    • "Topic 10" { Conditions: Variable["Topic"]==10 }
3. To start the conversation and have it jump to a specific topic node:

Code: Select all

DialogueLua.SetVariable("Topic", 3); // Jump to topic #3.
DialogueManager.StartConversation("My Conversation", actor, conversant); 
BTW, you may find it helpful to keep in mind that you can link across conversations. It might be easier to organize each topic as a separate conversation, and link to those conversations from your starter conversation.
drod7425
Posts: 11
Joined: Thu Jan 15, 2015 8:59 am

Re: Jump to Node from Anywhere in Conversation

Post by drod7425 »

3. To start the conversation and have it jump to a specific topic node:

CODE: SELECT ALL
DialogueLua.SetVariable("Topic", 3); // Jump to topic #3.
DialogueManager.StartConversation("My Conversation", actor, conversant);
There is a property of the conversation that precludes this option: the conversation starts out with a linear back and forth before it reaches the 10-root conversation split. The structure of conversation is roughly (sorry, I think my spaces get removed. hopefully, it is clear enough):

[]
|
[]
|
[]
|
[]
|
______________________________
| | | | | | | | | |
[] [] [] [] [] [] [] [] [] []

So I can't start the conversation anew when I want to jump to one of the ten, because the player would be forced to go through the intro.
BTW, you may find it helpful to keep in mind that you can link across conversations. It might be easier to organize each topic as a separate conversation, and link to those conversations from your starter conversation.
We have talked about splitting up the conversations. Unfortunately, many of the 10 sub-conversations link to the middle of other sub-conversations. To split that up would introduce even more complexity without removing the need to link to a specific node.

I suppose I could use a mixture of your suggestions by splitting up the intro and the sub-conversations into 2 conversations and then using the variable settings, but honestly the best solution would be the ability to jump to a specific node within the conversation. Is this not possible?
User avatar
Tony Li
Posts: 21026
Joined: Thu Jul 18, 2013 1:27 pm

Re: Jump to Node from Anywhere in Conversation

Post by Tony Li »

It's possible, and you can certainly do that. I was just suggesting an approach that I think is a little tidier.

Let's say your conversation looks like this:
(I wrapped the diagram in [ code ] tags.)

Code: Select all

                   [A]
                    |
                   [B]
                    |
                   [C]
                    |
                   [D]
                    |
 _____________________________________
 |   |   |   |   |   |   |   |   |   |
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10]
Are you saying that, the first time the conversation runs, it will follow nodes A-B-C-D-#, where # is one of the ten? And on subsequent runs, it will jump straight to D? D-#? Pictorially:

Code: Select all

                   [A]----
                    |     |(2nd run)
                   [B]    |
                    |     |
                   [C]    |
                    |     |
                   [D] <--
                    |
 _____________________________________
 |   |   |   |   |   |   |   |   |   |
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10]
drod7425
Posts: 11
Joined: Thu Jan 15, 2015 8:59 am

Re: Jump to Node from Anywhere in Conversation

Post by drod7425 »

Haha your diagram looks very good. What I was aiming for.

I think I may be starting to understand what you are proposing. Are you saying that instead of having just the 10 nodes coming off of 'D' (which are set up to wait on 'D' for the player to choose 1 of them), also add 10 nodes coming off 'A' with a lua variable condition and paths going to the appropriate topic? For example, if the value of Topic were equal to 3 - the conversation will automatically move from 'A' to the "Topic==3" node and finally onto the #3 node? Or if the value of Topic were equal to -1, from 'A' to 'B'?

That's probably doable. But would the lua variable be global? Would I need to reset this if I had another conversation with topic selection?

And let's say I wanted to do this with magic numbers and a whole host of ill-advised strategies, is there a method I could use to jump to a specific node from within a conversation without starting the conversation over?

EDIT: We're using ChatMapper. The script often gets changed up until the delivery date. Is there a way to define the variables and conditions within ChatMapper? If this can only be done within Unity, we'll lose the variable information every time we import new changes.
User avatar
Tony Li
Posts: 21026
Joined: Thu Jul 18, 2013 1:27 pm

Re: Jump to Node from Anywhere in Conversation

Post by Tony Li »

drod7425 wrote:Haha your diagram looks very good. What I was aiming for.

I think I may be starting to understand what you are proposing. Are you saying that instead of having just the 10 nodes coming off of 'D' (which are set up to wait on 'D' for the player to choose 1 of them), also add 10 nodes coming off 'A' with a lua variable condition and paths going to the appropriate topic? For example, if the value of Topic were equal to 3 - the conversation will automatically move from 'A' to the "Topic==3" node and finally onto the #3 node? Or if the value of Topic were equal to -1, from 'A' to 'B'?
Exactly. You can use a couple slightly more advanced features to make it even easier:

1. Put a Group node between [D] and the topic nodes. A Group node is one in which you've ticked the "Is Group" checkbox. It's like an empty node that passes through to all of its children. It's a convenient way to group nodes together and point to them with a single link instead of separate links for each child.

2. Add a link from [A] to the Group node.

3. Set the Conditions on [1], [2], ... [10] (e.g., Variable["Topic"]==1).

3. Inspect the link between [A] and . Set the Priority to BelowNormal. The Dialogue System considers links by priority tier. It will check the Normal priority link from [A] to the Group node first. If any of the topic nodes are true, it will choose that node. Otherwise, after checking all those links, it will check the BelowNormal link from [A] to . Since this link doesn't have a condition, it will choose .

Code: Select all

                   [A]----
    BelowNormal-->  |     | <-- Normal priority
                   [B]    |
                    |     |
                   [C]    |
                    |     |
                   [D]    |
                    |     |
                 [group]<-
                    |
  ___________________________________ 
 |   |   |   |   |   |   |   |   |   |
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10]
drod7425 wrote:But would the lua variable be global? Would I need to reset this if I had another conversation with topic selection?
Yes, variables are global. Use a variable name that's unique to each conversation. For example, if you have ConversationXYZ, define a variable ConversationXYZ_Topic.
And let's say I wanted to do this with magic numbers and a whole host of ill-advised strategies, is there a method I could use to jump to a specific node from within a conversation without starting the conversation over?
Effectively, yes. You can write a method to stop the current conversation and immediately restart it at a specific dialogue entry ID, as in the Backtracker script in this post.
drod7425
Posts: 11
Joined: Thu Jan 15, 2015 8:59 am

Re: Jump to Node from Anywhere in Conversation

Post by drod7425 »

Awesome. Lots of great information. Thank you!
User avatar
Tony Li
Posts: 21026
Joined: Thu Jul 18, 2013 1:27 pm

Re: Jump to Node from Anywhere in Conversation

Post by Tony Li »

Happy to help! I realize it's a lot of information. If you have questions at any point, don't hesitate to post here or email me at tony (at) pixelcrushers.com.
Post Reply