NodeCanvas Forums › Support › Ultimate FSM/Dialogue/Subdialogue confusion
I just started implementing dialogs and I run into tons of confusion how blackboards are handled. Super confused, because we had working use cases with 1.x that now either just don’t work anymore or need to be handled differently. But let me show you a (in our project very common) example of a setup:
Three DialogueTree Assets: DialogueA, DialogueB & DialogueC
Scene Hierarchy:
– FSMOwner (with bound FSM)
+ DialogueTreeController (referencing DialogueA asset)
DialogueA has a “Sub Dialogue” node referencing DialogueB
DialogueB has a “Sub Dialogue” node referencing DialogueC
The BoundFSM in the Scene has a “StartDialogueTree” action that references the “DialogueTreeController”
Now, I have used blackboard variables in all four graphs.
My goal: Have them all reference the same variables in the same blackboard because:
– I want one central piece where the Truth is stored (Blackboard component on FSM)
– I want to have acces to the same information in all parts invoked by the FSM (SubFSMs, Dialogs, …)
– the FSM is the main logic controller for the Thing I interact with
– the Dialogs need access to this information to show the right dialogue threads
– decisions in the dialogue should be persisted until I interact again with the Thing, so it doesn’t “forget”
Now, I tried very different combinations on how to get this goal achieved, but it just don’t work out. The dialogs seem to have isolated blackboards, I don’t see any way to pipe the FSM blackboard into the dialogs. But what astonishes me most is that a SubDialog doesn’t run off the parent dialogs blackboard apparently! It’s isolated as well, making the whole sub dialogus pretty useless because I cannot exchange any information between parent and child dialogue. I tried experimenting with overriding agents and event tries to use a “DialogueActor” component on my FSM that is passed to the StartDialogueTree action but it didn’t help.
So my final conclusion is, either I’m getting everything wrong and the right workflow just evades me or this use case is just not supported.
Hey,
As far as piping a SubDialogue tree’s variables to the parent Dialogue Tree variables, this can be done through the inspector of the SubDialogue node and in the “Mapping” section. In that inspector section, all variables existing in the sub-dialogue tree local blackboard will be listed and you have the option to map these variables to the variable of the parent dialogue.
In this example bellow, the sub dialogue tree assigned in the SubDialogue node, has 2 local variables, myFloat and myString.
Sub-Tree’s “myString” variable is mapped to the parent/current “myString” variable, while “myFloat” is not mapped and left to NONE.
What will thus happen, is that as soon as the sub dialogue tree is executed, it’s local variables will be set according based on this mapping.
This is very similar to how you would for example set the parameters of a task, but instead in this case we are setting the variables of the subtree.
This way, a dialogue tree asset can easier be reusable in many different parent dialogue trees without relying in having the same parameter names like it was before, but rather by mapping/parametrizing it’s variables.
This is generally, the way I am heading towards the other systems (FSM, BT) to also work as far as SubGraph’s go.
Now, as far as piping the parent FSM blackboard variables to the dialogue tree started by the “Start Dialogue Tree” action, this is indeed not possible and missing, BUT, in the next version there will be a SubDialogue node for FSMs (similar to how there was one in version 1.x), where piping data will work pretty much the same way as explained above. I can actually send you the node before the new version hits the asset store.
Let me know your thoughts on these.
Thanks.
Join us on Discord: https://discord.gg/97q2Rjh
I must be doing something wrong. I tried the binding and it didn’t work properly, so I got back and put a minimal case together and I just can’t get it to work:
I’ve attached the scene + assets. It should run together with the default 2.6.2 package. I always get the result “Count should be 2, but is 1”.
Hey,
You aren’t doing anything wrong really.
It’s is just that SubTree does not affect the parent tree variables, but rather only the other way (Parent affects SubTree). It’s one way.
I could add an option for this though, so that it is two-ways, meaning that as soon as the SubTree is finished, it writes the variable value back to the parent tree.
Let me know if that is something required.
Thanks.
Join us on Discord: https://discord.gg/97q2Rjh
Yeah that’d definitely would be something that would be very appreciated! I just looked at the SubDialogueTree implementation and actually I think it wouldn’t be that hard to do myself (Just syncing variables back in OnSubDialogueFinish if I got it correctly).
Edit: That does work pretty well, I even got a custom StartDialogueTree action working in my FSM with the same variable binding code as in SubDialogueTree. The only drawback I see now is that the bound variables won’t update until the dialogue finishes but I don’t see an easy fix for that.
Hey,
Yes, one way to do it is indeed to sync the variables back OnSubDialogueFinish like you said and also what I was planning to do.
If syncing variables back even before OnSubDialogueFinish is required, that could be done by subscribing to all the mapped variables ‘onValueChange’ event and do the sync when the event is raised. This will require a bit more work but maybe it’s worth it. I will take a look at heading towards that direction.
Thanks 🙂
Join us on Discord: https://discord.gg/97q2Rjh