NodeCanvas Forums › General Discussion › Passing information between Dialogue Tree and Scene
Tagged: dialogue tree, Game Scene
Hello All,
I was wondering how you pass information from the Dialogue Tree to your game scene and vice versa. For example, if at a certain point going through the dialogue, you want to enable Input Fields on the Canvas, then tell the Dialogue Tree to continue after the Input Fields are filled. Thanks very much!
Hello,
Probably the best way, would be to use the Action Node and [create a custom ‘ActionTask’] within which you can do whatever desired.
You could for example create a custom ActionTask, which enables the input in question and awaits use submission. Once submission is done, you can then call ‘EndAction’ within that custom ActionTask, so that the Dialogue Tree continues with the next connected child node.
If you need any help with creating custom action tasks, please let me know!
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh
Thanks so much Gavalakis! I will be playing around with the ActionTasks today. I assume that I have to call to a script somewhere for custom ones. I’m not sure how to ‘EndAction’ though. Any help relating to custom ActionTasks you could send my way would be greatly appreciated. Thanks again.
Hey,
EndAction, is simply a function you need to call from within your custom Action Task, to signal the end of the action 🙂
Please take a look at the documentation about Creating Custom Tasks on section 4.0 and let me know if you have any questions at all 🙂
[LINK].
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh
Hello again,
I have been looking through the Action Tasks in the Dialogue Tree Nodes, but I still do not understand how to make a simple custom task. I see many options of already built in tasks, but not how to implement my own script for a specific node. If I want to do something like the Simple Action example in the link you sent, and in my attachment, on a particular node, can you tell me how to implement that specifically? Thanks so much!
Hello again and sorry for the late reply.
If you want to execute an Action Task within a DialogueTree, you just need to add the node named “Task Action” in the DialogueTree and then from within it’s inspector, hit the “Assign Action Task” button. That will open up a menu from wherein you can choose among all existing ActionTasks that come with NodeCanvas as well as the custom ones you have made, and “assign” that ActionTask to the node.
As a result, when the “Task Action” node is called in the DialogueTree, so will any Actions that you have assigned in that node.
Please let me know if that clarifies your questions.
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh
Thanks again for the help. What I was missing was adding a script to the Dialogue Tree in the Unity Inspector and making a public method that can be chosen in the Action Task. Now that I am up to making custom scripts to perform actions, I am wondering if there is a specific call like “DialogueTree.Pause()”, or something along those lines to that I can stop the dialogue from continuing on a click until I allow it. Any Pause, Stop, Continue, Go, or something along these lines that I can call in the custom scripts would be great. Does such a thing exist?
Hey,
Yes, you can pause a currently running DialogueTree, by having a reference to the DialogueTreeController component and then calling:
1 2 3 4 |
var dialogue = GetComponent<DialogueTreeController>(); dialogue.PauseBehaviour(); |
To continue on a paused DialogueTree, you can similarly call:
1 2 3 4 |
var dialogue = GetComponent<DialogueTreeController>(); dialogue.StartBehaviour(); |
( StartBehaviour will either start the dialogue if it’s not running, or continue from wherever it was paused if at all )
The above examples get the DialogueTreeController component from the same gameobject the example script is attached, thus in this case that example script code should be attached on the same gameobject that DialogueTreeController is found, but that is of course not necessary to do it that way. 🙂
Let me know if the above help, or if you need any further clarifications.
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh
Perfect. This is exactly what I need. Is there a Library of methods like these under DialogueTreeController that I could look at to know all the available methods?
Hey,
Great. Glad to know this helps.
The DialogueTreeController has a few other similar methods as well.
What do you mean by “library of methods” ? 🙂
Thanks.
Join us on Discord: https://discord.gg/97q2Rjh
Basically, I just mean is there a list of similar methods that I can see, so I know what else is possible
I have a new issue where EndAction is being called after an Input Field is filled and everything checks out, but it gives a Null Reference Exception. There are more Nodes after this task in the Dialogue Tree, so I do not know why this would come up.
Hey,
If you are using MonoDevelop, Visual Studio or similar, you can just get the rest of the available methods with the IDE’s intellisense, but I am sure you know that already 🙂
There are a couple more of similar methods as said before, those being, a few different StartDialogue
overloads, StopDialogue
, PauseDialogue
and SetActorReference
. The base type GraphOwner
, where DialogueTreeController
derives from, has a few more as well.
Regarding your EndAction issue, are you referring to a custom ActionTask? If so, can you please share the code?
What/where exactly is the Null Reference Exception? Can you please post the log?
Thanks.
Join us on Discord: https://discord.gg/97q2Rjh
Alright, so I solved the Null Reference Exception that was stopping me from moving through the Dialogue Tree at all. Now, what I want to do is after a button is pushed, I have a script that goes through some validations and then when everything clears, I want to call EndAction to move on in the Tree.
I tried making a script that just calls EndAction, but because it has to be ActionTask and not MonoBehaviour, I could not attach it to anything. When I try to call a public method in the script that contains EndAction from a separate script, it gives a Null Reference Exception. If I attach the script containing EndAction to a button, the methods do not show up.
So all of this right now is where I am stuck. I am really sorry this thread has gone on for some time, but I appreciate all the help
Hello,
No problem about the big thread, but I am a bit puzzled about your last question/issue 🙂
As you know, EndAction, is a member method of ActionTask and as such you need a reference to the action task that you want to end, and call EndAction in that action task.
Is it possible for you to please send me an example project to (support_AT_paradoxnotion.com), showing the issue you are facing as well as what and how you are trying to achieve as an example. I am sorry, but it’s quite hard for me to understand your setup and how things are coupled/woring in that setup. If possible that would be great.
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh