Open laurentsenta opened 1 week ago
Your expectations are correct here, whenever a new transition is taken while another one is pending this new transition should replace the pending one.
However I can't seem to reproduce the behaviour you have observed. I have written a test to check for this:
extends StateChartTestBase
# Checks that multiple delayed transitions work.
# https://github.com/derkork/godot-statecharts/issues/148
func test_multiple_delayed_transitions_work():
var root := compound_state("root")
var think := atomic_state("think", root)
var explore := atomic_state("explore", root)
var inspect := atomic_state("inspect", root)
transition(think, explore, "pick_destination")
transition( explore, inspect, "target_reached", "1.0")
transition( explore, think, "", "2.0")
await finish_setup()
assert_active(think)
# when I pick a destination
send_event("pick_destination")
# then I should be exploring
assert_active(explore)
# when I now reach the target
await wait_seconds(1.1, "wait for target reached")
send_event("target_reached")
# then after 1 second I should be inspecting
await wait_seconds(1.1, "wait for inspect")
assert_active(inspect)
and the test works with 0.17.0. So I also re-built the setup manually with some buttons to trigger the events and there it also works as expected.
https://github.com/user-attachments/assets/5e3e0e9d-cd17-4468-ae7b-186ab6f59539
Could you check the history tab in the state chart debugger? This tab shows all incoming events and reactions to them, so maybe you can see there what causes your problem. My guess would be a typo in the event name for on_target_reached
.
Hi there, thanks for maintaining the library,
I'm confused how to deal with delayed automatic transitions,
A behavior I'm trying to implement:
My main issue is with the Explore state and transition:
on_target_reached
is a transition with event:target_reached
and delay: 4.0son_timeout_think_again
is a transition with no event and delay: 8.0sMy expectation:
target_reached
signal after a second (for example), we schedule that transition and take it after 4.0s. That transition is supposed to "complete" earlier.What happens (0.17.0):
It seems like a bug, doc says:
Would it be possible to configure/fix this behavior?