derkork / godot-statecharts

A state charts extension for Godot 4
MIT License
679 stars 33 forks source link

StateIsActiveGuard not working with delayed transitions #109

Closed DrDonze closed 2 months ago

DrDonze commented 2 months ago

Hello, First of all, thanks for this amazing project ! I've noticed a problem when I'm relying on a StateIsActiveGuard for a state transition when the state I'm listening to has a delayed transition.

For example, there is a state called WalkState and I have also other branches for managing animation with another state called WalkAnimation. My animation transition to WalkAnimation rely on a StateIsActiveGuard listening to the activation of WalkState. The problem is, if there is a delay to WalkState (delay_seconds property of the Transition), the WalkAnimation doesn't transit as if WalkState is not active (but it is active on the debug). If I disable the delay, it is working as expected.

Am I the only one ? Am I doing something wrong ?

derkork commented 2 months ago

This sounds a bit like https://github.com/derkork/godot-statecharts/issues/103 to me. Guards do not trigger any transitions, they can only prevent transitions from happening. You need to have something that triggers the transition to WalkAnimation. If you can post your state chart I might be able to provide a suggestion on how to get the behavior you want.

DrDonze commented 2 months ago

Thank you for your reply. Yes you're right it's exactly the same problem as #103, I thought transition with delay would still be processed as a "trigger" but I understand the limitations. I'll find a better way to organize my tree. Thanks for the kind support !

derkork commented 2 months ago

Well, that being said this has come up enough times that I consider checking automatic transitions on every state change. I will need to find a way to make this less expensive and most of all predictable.

derkork commented 2 months ago

I opened https://github.com/derkork/godot-statecharts/issues/114 for this. I still need to think about the possible side effects but I think this would be really nice to have.