derkork / godot-statecharts

A state charts extension for Godot 4
MIT License
761 stars 39 forks source link

Provide signals for `_input` and `_unhandled_input` #4

Closed ibokuri closed 1 year ago

ibokuri commented 1 year ago

If possible, I think that states should provide signals for _input and _unhandled_input, similar to how there are signals for _process and _physics_process. This change would allow for slightly more optimal code since the input functions only fire whenever there's a change in input, whereas the process functions fires every frame.

Currently, my workaround for this is to, in my player's _unhandled_input function, emit a state event (e.g., "interact") and then have a signal handler, which is connected to the event_received for all relevant states, handle the event appropriately. This works fine, but is a bit hacky and you do lose all information about the input event itself.

P.S. I've only just started using godot-statecharts and it has already been so useful for me! Thanks a lot for the awesome plugin!

derkork commented 1 year ago

Hi @ibokuri this sounds like a useful addition. I'll add this in an upcoming version.