Download

Boolean in Behaviour Tree

I was following a tutorial and I came across this issue which seems weird.

I have a tree which an NPC patrols and increments a patrol index until he reaches the end of the vector array.

The issue I was having was in the “ShouldRepeatPatrol” boolean part of the tree.

If i checked if the value of ShouldRepeatPatrol was true and then ticked the success box the tree never entered into the DecrementPatrolIndex part of the tree to make him go backwards through the points. (See LoopPatrolBool)

Now he just loops regardless of the setting of Should Repeat Patrol.

It seems unless I fail both branches of the LoopPatrol function it will never move into the DecrementPatrolIndex which seems counterintuitive when I am checking whether I want him to repeat or not.(See RepeatPatrolBool)

Sorry if this is not 100% clear I am still struggling to understand exactly how these nodes work in tree,s

Many thanks for any replies!

I think your selector always succeed with the first node which always succeed :


You should create a Decorator that check the Boolean bShouldRepeat, something like that :

Cool I will use a Decorator instead, Many thanks for the reply!