Performing an action every few seconds using a BT_service

cutting right to the point. How do I use a service to run a behavior every 30 seconds? This code is running infinite at the moment; rest of the behavior tree isn’t running. I just want this AI to perform this simple behavior once every 30 seconds. Any interval I place in the service makes it run infinite.

I reused the same decorator for this branch as the others because its a boolean check with different blackboard keys. Print Task is a filler task for the real one not implemented yet.

The service gets reset every time control flow leaves the BT sub-branch. This has been fixed in 4.8, but for now try putting the service up at the root.



Roots of Behavior Trees can’t attack services. I might have to think of a different way of adjusting this tree because this doesn’t work.

By root I mean the first composite node of the tree. What you see as a Root in the editor is a “fake” editor-time node. I guess we need to rename it :slight_smile:

Hmmm, the way I designed my behavior tree has an infinite loop decorator on the 2nd composite node; the first one will never be read again if I think I know behavior trees.

I tried on the 2nd composite node; attaching the service, but the infinite running of the behavior without running the other parts of the tree still exists.

Are there any alternative? I guess I can try to make this behavior run with a random chance.

You can try implementing a custom service that would be setting up and using a timer. Or you can have this logic in AIController class’ BP altogether or alternatively kept in sync with BT using blackboard. Not every single thing has to be done in BT :wink: