limbonaut / limboai

LimboAI - Behavior Trees and State Machines for Godot 4
https://limboai.readthedocs.io/
MIT License
1.23k stars 48 forks source link

A way to update HSM in both idle and physics process. #165

Open hayahane opened 3 months ago

hayahane commented 3 months ago

Problem statement

I'm trying to use LimboHSM for not only AI but character controller. I usually expect a state to update like:

Proposed solution

Alternatives

Don't know.

limbonaut commented 3 months ago

LimboHSM only supports a single update function in its implementation. It's not specific to any particular update time. In update_mode, you can specify when the state machine should be updated, and you can choose between idle process or physics process, or opt to update it manually. Some folks reported, that they were using manual update to reduce the rate at which agents update when off-screen. Since the _update function is not equal to idle update (it's not even the default), it won't be a good solution to simply add _physics_update on top of this system. I don't particularly see how we could support two separate update functions in the system described above. I wanted to say that you could potentially use _process_input for that, but it looks like it's currently bugged, and I'm in the process of fixing it. _process_input should be automatically enabled/disabled when substate becomes active, but that will come in the next release.