How to jump to part of tree when boolean changes value?

mostlyhuman

Member
I have a common setup in this tree where the agent Wanders until it sees the target using a conditional abort. I have a variable called isAggressive that is set to true if the player comes up behind the agent and attacks (this is handled through an external script linked to the behavior tree variable) , when this happens I want the tree to instantly move to the Parallel Complete part of the tree labeled in green. How would I go about doing this? Having isAggressive changing to true cause a jump to this part of the tree? Thank you for any help and specifics are appreciated as I am kinda slow :)
btTree.png
 
Last edited:
Behavior trees are not able to directly jump between nodes like you can with finite state machines. You'll need to restructure your tree so that the correct conditions place the tree in the desired branch. One thought is that you could have a conditional abort check for the isAggressive flag.
 
Thank you Justin, can you offer any specifics on where I would place that I’m having trouble visualizing how to make a conditional abort work to achieve that.
 
As the tree gets larger it gets harder and harder for me to debug. I suspect that if you place a conditional check for isAggressive near the Can See Object at the top you'll be able to jump to the Parallel Complete branch, but this will likely take some playing with in order to get right.
 
I'm not an expert in conditional aborts, have no idea how they work with multiple conditions. But I would suggest to change your design slightly, to get more realistic and logical AI behavior. That is, when getting damaged from behind, AI shouldn't automatically attack, but rather turn around and try to find the enemy. What if attacker uses some sort of invisibility, or shoots from afar and immediately hides? Situations like these need to be considered.

I suggest to add another branch under the main selector. I don't have tactical packs, so I simulated this logic with some basic tasks. See the demo:


While wandering it evaluates both conditions simultaneously. If IsAttacked changes, it investigates for some time, and returns to wandering. If EnemyInSight changes at any moment, it aborts both lower priority branches and immediately attacks.
 
Last edited:
I'm not an expert in conditional aborts, have no idea how they work with multiple conditions. But I would suggest to change your design slightly, to get more realistic and logical AI behavior. That is, when getting damaged from behind, AI shouldn't automatically attack, but rather turn around and try to find the enemy. What if attacker uses some sort of invisibility, or shoots from afar and immediately hides? Situations like these need to be considered.

I suggest to add another branch under the main selector. I don't have tactical packs, so I simulated this logic with some basic tasks. See the demo:


While wandering it evaluates both conditions simultaneously. If IsAttacked changes, it investigates for some time, and returns to wandering. If EnemyInSight changes at any moment, it aborts both lower priority branches and immediately attacks.

Thank you abc123! Must appreciated.
 
Top