Glad you found a fix, well done!
Aha! This is what I needed to know. I reproduced the problem on my end, and it looks like after all of this discussion, I think you were in fact creating a circular reference after all.
After some extensive testing, I managed to make your original approach work. The problem was that if every scene involved in the control loop (level 1, level 2, level 3, win screen) has an @export PackedScene
belonging to that set, the control loop breaks. Not 100% certain as to why, but it definitely has to do with the scene not being unloaded properly before code tries to load it again. I feel like it’s some sort of off-by-one bug in Godot’s scene-changing code itself, because inserting the start menu (which has no @export PackedScene
loop member) into this loop magically made everything work. I can’t get closer than that to a full explanation I’m afraid; it’s a bit beyond what I know.
(It’s also worth noting I didn’t have a broken dependencies popup, so there may have been something additional in your project that I couldn’t reproduce).
I had lots and lots of problems with this when I was extending these projects after finishing the lessons, but they manifested differently for me than they did for you. Personally, I’ve found that loading scenes by filepath has been far more reliable than using @export
variables to pass scenes into the inspector directly (probably because it breaks apart these control loops), so for any future projects, I’d highly recommend working around that technique. @export
s can still be part of the solution though, if you want; a few ideas:
- Ints and parsing
- Dictionaries
- Arrays
- Enums
Congratulations again on fixing the issue, and good luck with the rest of the course =)