A FlowCanvas FlowScript can be used as a nested Behaviour Tree node to model the node’s behaviour completely with visual scripting. After you have downloaded the FlowCanvas bridge extension, it will be possible to add such a nested FlowScript through the context menu and found under the “Nested” category.
In the example here, we use a FlowScript as a child of a Behaviour Tree’s Sequencer.
The FlowScript’s OnEnable, OnUpdate, OnDisable events will fire respectively when the nested FlowScript in the Behaviour Tree is enabled, updated or disabled.
Per usual, a Sequencer (and most Behaviour Tree nodes), expects a return result of Success or Failure, based on which the Sequencer will continue executing it’s child nodes or not, for Success/Failure respectively. Within the FlowScript, the ‘Finish’ node has to be used to return control back to the Behaviour Tree, using the Finish node’s boolean port to determine returned Success or Failure.
Without a Finish node called, the FlowScript will continue run indefinitely, thus returning Status.Running back to the Behaviour Tree forever, unless the Behaviour Tree Nested FlowScript Node is interrupted by any means.
Generally speaking, for all purposes you can treat a Nested FlowScript Node as a normal Action Node, which though instead of having a Task assigned, it’s functionality is modeled with a FlowScript.
Last but not least, all Variables used in the Behaviour Tree, are propagated down the nested FlowScript like all other nested Graphs work.