Closed bitegw closed 3 months ago
I have added a wrapper for CallDeferred
and also a a MethodName
class holding the proper method names of the StateChart
class in GDScript land, so it's also safe to use from C# without having to type any strings.
Regarding the other two things:
transition_pending
signal is emitted which contains original transition time and remaining transition time and can be used to drive an UI element. Would that work for your use case?Active
property, e.g.:StateChartState _some_state;
void _Ready() {
_some_state = StateChartState.Of(GetNode<Node>("%Airborne")); // using a scene unique name here
}
void SomeMethod() {
if (_some_state.Active) {
// do things..
}
}
I ran into an issue where I tried to set an expression in _Ready when the StateChart wasn't initialized, this gave me an error that told me to use call_deferred to set the expression instead, but StateChart does not expose it. A workaround is to call it on the (not yet converted to StateChart) Node, but the called function is a StateChart function so I find it a little weird to have to do this.
Also some suggestions: 1) I'm not sure if it's just my usecases, but I find I really often want to keep track of how long I've been in a state, or how long it's been since I left a state. It's a pain to manage this for every state so it would be good if states kept track of this automatically. These values could be used in code to control animation transitions, or to populate cooldown values in UI elements. 2) This might be something I missed but is there any way to get the active state (maybe entire state path) and check it? This also seems like a useful feature, but maybe I'm just misusing the state chart by doing this.