"If branch is interrupted"

Ell223

New member
Hello,

Is it possible to tell if a branch has been interrupted, and if it had, perform a task/run some code before it enters the new branch? Essentially, I have a branch which dequeues a game "task" from an object, this tells the NPC which resources it needs to go find and only one NPC can have this game task at a time. However if the branch gets interrupted by a conditional abort, by for example if it gets attacked by an enemy or numerous other reasons, I need to be able "reset" this game task so the gameobject can reassign it to a different NPC. But as far as I can tell, I can't infer if a branch has been interrupted in order to be able to do this.

Any ideas how to get around this? Or do I need to rethink my logic?

Thanks,
Elliott
 
There isn't a way to detect this but it is a relatively common use case so I plan on adding it to version 2 of Behavior Designer. For now you have to assume that the tree is in an unknown state and reset the variables when the new branch begins. This is the approach that I took for the Ultimate character Controller tree:

 
Top