Confused about conditional branching

eric

New member
I'm a little confused about conditional branching. Maybe that's not really a concept in behavior tree?

I have an NPC attacking my player using a repeater and a sequence. Once they get hit back I return false and this branch goes up to a selector which pushes me to the next branch.

Right now in that branch I have a sequence with one action which is dodge. But sometimes I might want the NPC to flee, or I might want him to use some ability. Maybe I'll base this on probability or maybe health of the NPC. In code I'd just have a few branches in an if or a switch statement. But that's not a thing here. So what's the right way to implement that? I saw conditionals and have written my own, but they only have an input.

Thanks!
 
What does your tree look like? If you want a random branch to run you could use the Random Selector. The same way to get an if statement within a behavior tree is to use the conditional task parented with a sequence.

-------Sequence
Conditional ---- Action
 
Top