Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event sent on state enter is ignored on parallel state #143

Open
derkork opened this issue Aug 19, 2024 · 2 comments
Open

Event sent on state enter is ignored on parallel state #143

derkork opened this issue Aug 19, 2024 · 2 comments

Comments

@derkork
Copy link
Owner

derkork commented Aug 19, 2024

Assume you have this setup:

ParallelState
  A
    on enter:  send_event("some_event")

  B ( compound )
    B1
       on "some_event" -> B2
    B2

If we start this, A is entered, which triggers the sending of some_event. But because B is not yet entered (in parallel states states are entered one by one), B is technically not yet active which is why B1 never gets the some_event event delivered so while we should end up with state B2 active, we end up with B1 active. We will need some two-phase state entering mechanism, where we first finalize all state entering and only fire the event handlers once the new state is propagated through the state chart.

@derkork
Copy link
Owner Author

derkork commented Aug 19, 2024

As a workaround one can delay the sending of the event by one frame, e.g.

func _state_a_state_entered():
    $StateChart.send_event.call_deferred("some_event")

@derkork
Copy link
Owner Author

derkork commented Aug 22, 2024

We will also need this same process for state exiting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant