AI behavior tree loop behavior

Hi Community,

It seems in AI behavior tree, if a custom task doesn’t call “Finish Execute” (in response to “Receive Execute”, or “Receive Tick”), the behavior tree branch the task is sitting on will be locked, and the branch will be executed again and again (so a good opportunity to handle the Receive Tick event), until “Finish Execute” is called eventually (based on a condition). This essentially forms a loop, which should be similar in effect to what the “Conditional Loop” (or “Loop”) decorator does.

Based on my experiment, it seems in “latent” task, I can conditionally only invoke “Finish Execute” (either success or fail) when some condition is met, while other times I just leave the task blueprint return without invoking “Finish Execute”, so the behavior tree branch is locked that the latent task will be repeatedly executed without being switched to any other branches. So I can effectively do a continuous latent attack until the target is destroyed, for example.

I am guessing that the “Conditional Loop” or “Loop” decorators would just swallow the task “Finish Execute” status, and only break when its own condition is met.

Is this observation correct?



i have tried, but i can’t understand how “Loop” decorators work…

yes, you can “play” with Finish Execute true/false for lock the behaviour in one task.

Loop work like a Finish Execute->true counter.

It’s kinda correct, but it’s not how it’s done if you look in the source code. At the end of the execution of the node it’s attached to, the Loop decorator will check if it should loop (non finished yet or condition is met or infinite) then it will reset the next node to execute back to the beginning of the loop.