Running behaviour tree only once

Hey,

Is there a way to run behaviour tree only once by default? I just need it to do some specific things, but once all tasks are done, it should stop running until the next time it needs to run (minutes later).

Ideally it would simply star on a BP event and simply run once until the event is called again.

Thanks!

You could add a decorator on some top level node in your behavior tree, which checks a boolean “bAllowedToRun” and if it’s false it doesn’t do anything else.

Then when you want to run the tree once, you set bAllowedToRun = true on your event. And at the end of the behavior tree you set it back to false.

Yeah, but then it still is a ticking behaviour tree for each of the actors, checking if that ever gets set to true.
I know it’s technically not called “ticking”, but “event based”, but under the hood it still checks the variable…

I really would like to do away with that overhead as it’s entirely not needed.

You’re right, it will be constantly checking that variable. But you might be overthinking this. Checking some additional booleans will have no measurable impact on your performance.

Maybe I am overthinking it, but with many-many AIs it could add up.

In any case it does not seem like there is a way around it.

Thanks for your help!

stop logic

2 Likes

Thanks! That’ll probably do the trick.
I wonder if that can be called from a task… I know epic is not keen on that sort of stuff, but let’s see if it works.

Surely you can, it is a function in the controller, there is nothing ugly to call it.

Although I have it as a function in my IAcontroller, because I call it from time to time.
It is much cleaner than having a decorator with a bool.