First of all I want to say that, having used Behave extensively prior to this, I am very impressed with NodeCanvas so far, and hope to put it to good use. However I have run into an issue with trying to use the same nested sub-tree more than once in the same behavior tree. The problem is that multiple instances of the same nested sub-tree share the same state, meaning that if the first instance is executed and returns Success, then when the tree gets to the second instance, it uses the Success state of the first instance and doesn’t execute the sub-tree again. I was able to make the system work as I expected by modifying BTSubTree.OnExecute() to reset the sub-tree node if it returns anything but Running (code below), but I am not yet convinced this will not have side effects; however, it seems to be working fine for my needs so far. What do you think?
It seems I have a subtree instantiation bug here after some refactors :(, meaning that the subtree is not instantiated and instead the exact same instance is used in some cases. I will have to fix this ASAP.
The fix you’ve proposed will work fine for as long as the subtrees are not under a Parallel node, although it would be better if you first check/reset the subtree and then call execute: