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

Double _on_enter() due to compound_state #1

Closed
Remi123 opened this issue Apr 6, 2023 · 2 comments
Closed

Double _on_enter() due to compound_state #1

Remi123 opened this issue Apr 6, 2023 · 2 comments

Comments

@Remi123
Copy link

Remi123 commented Apr 6, 2023

It took me a while to reproduce but I found out that some architecture can trigger on_enter and on_exit twice.

Small explanation of my nodes :
I have a character that move in the Move state, then once I click it goes into Jump state and immediatly transition to a Falling state.
I've connected the on_enter() function of the Move and Falling state to a function that print respectively Move and Falling enter with the timestamp.

With this setup :
image
Produce this result :
image

However this architecture :
image
Airborne also print its name on enter
Produce this result :
image

During transition, it seems that compoundstate trigger the on_enter() and on_exit of his children if it's the target node. I've looked into the reference statechart.io website to see if it's an intended behavior, but didn't find any. I believe this is unintended behavior.

However I'm not familiar enough with the code to know why the root compoundstate isn't affected.

Thank you

@derkork
Copy link
Owner

derkork commented Apr 6, 2023

Hey Remi123, thanks a lot for reporting this. It is indeed not intended behaviour. The "Airborne" state will activate it's default child state when entered. However since this is part of a transition it actually should not do this. I have added a fix for this and will release an update with it. I have also added some improvements to the state chart debugger so it can track state change events for you without you having to litter your code with print statements:

image

In the screenshot you can now also see the fixed behaviour, when AA transitions to ABA , ABA will only be activated once.

@derkork derkork closed this as completed in 3673fe5 Apr 6, 2023
derkork added a commit that referenced this issue Apr 6, 2023
@Remi123
Copy link
Author

Remi123 commented Apr 6, 2023

Thank you that was fast

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

2 participants