limbonaut / limboai

LimboAI - Behavior Trees and State Machines for Godot 4

Home Page:https://limboai.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Event-based update for BT.

ODtian opened this issue · comments

Currently, the BT update mode primarily invokes the _tick() method to poll the current state at each frame. This approach is generally inefficient when executing time-consuming asynchronous functions, such as playing animations, navigating, and timing. It may cause a useless function call just to poll whether it is finished.

For actions based on signals, implementation would be straightforward: set the update mode to manual upon node setup, and switch it back to auto upon exit. For user convenience, adding an option to automate this function for task nodes would be beneficial.

The decision to use a first-gen approach to behavior trees was made for simplicity, usability and maintainability sake. Concerning polling, it's all up to the implementation of the task. You can have _tick return a cached status, instead of polling, and still rely on signals for time-consuming external functions. Event-based approach can be reevaluated for version 2.0. It will likely cause major compatibility breakage. However, it may be possible to have a less invasive, hybrid solution, that would keep the API mostly intact. I'm not sure if it's actually worth it to optimize method calls like this (taking in the context of a hybrid solution). Maybe for massive cases with hundreds and thousands of simultaneously active agents.