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

OnReady vars null on initial enter state #28

Closed
Red3Tango opened this issue Aug 31, 2023 · 3 comments
Closed

OnReady vars null on initial enter state #28

Red3Tango opened this issue Aug 31, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@Red3Tango
Copy link

Using vars that are set with @onready (or in _ready()) are still unset when the Initial State is first Entered.
Only workaround I have found, for nodes use $Node/Path or get_node(). For dynamic vars, would need to be hard-coded.

I have not found an elegant way around this to "fix", and there may not be. A note or warning may be nice about the load order of when in runs the initial state enter signal.

@Red3Tango Red3Tango changed the title OnReady vars null on default enter state OnReady vars null on initial enter state Aug 31, 2023
@derkork
Copy link
Owner

derkork commented Aug 31, 2023

I think this is caused by the recent change that ensures that state changes happen in the same frame. It could be fixed by delaying entering the initial state of the state chart by one frame, to ensure that the full tree is ready.

I'll build a new release with this change as i think this makes more sense than the current implementation but I will not be able to do it today. As a temporary workaround you can change this line in state_chart.gd which should delay the state entering by one frame:

image

@Red3Tango
Copy link
Author

I always forget that call_deferred() exists. Tested and can confirm this works.

@derkork derkork closed this as completed in 91b2a6b Sep 5, 2023
@derkork derkork added the bug Something isn't working label Sep 5, 2023
@derkork
Copy link
Owner

derkork commented Sep 5, 2023

Released 0.4.3 which has the fix built-in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants