On Abort

willij

New member
I have an external tree that claims something. When it is done with that thing, it will unclaim it within the tree. However, if the tree is aborted, it will not be unclaimed and no other agent can use it.

Is there anyway I can tell when a external tree is being interrupted and run some behavior before it gets interrupted?

Thanks
 
Can you describe what you mean when you say that it claims something? When the game starts the Behavior Tree component will load all of the external trees, and then it's like a normal part of the tree. There isn't a way to return that external tree.
 
Yeah sorry, I should have done a better job of explaining. The fact that this happens in an external tree is irrelevant. I just meant a subtree. I want to know if there is a way to tell when a specific subtree is aborted. I could put the "unclaim" script in every possible tree that can abort this tree or cobble some bool / event together but I just wanted to check if there's a built-in way to basically say, "hey, if this subtree is cancelled mid-run due to a conditional abort, run this code".

The claiming unclaiming thing is just the agent marking an object for its use. If, for example, the agent gets attacked by something and the "hurt" subtree aborts the current tree before it unclaims that object, no other agents will be able to use that object. Basically it's like I give a key to an object to the agent and say, only you can open this door but then a wolf attacks him and he runs off with the key. I'd rather not use an on Update check on every single item with a key or copy pasting "give the key back" to every single tree that can abort this one so I'm looking for a better alternative.
 
Ahh, I see now. Besides the OnEnd method there's not a way to cleanup after a conditional abort. I have plans to add something like this to version 2 though.
 
I haven't had reason to use the OnEnd method yet. So it gets called in the current task when it gets aborted? That's good to know. However, the subtree in question has a lot of tasks so I would have to put the "give the key back" code in the OnEnd method in all of them since any one of them could be running when it gets aborted. Some of the the tasks are very general like move to position so I would rather not clutter their code.

It's great to know you're planning to add a solution in version 2 though! I'll put in a messy workaround for this temporarily and wait for the update.

Thanks for the help.
 
Top