[deleted]
[deleted by user]
Best
Open comment sort options
Best
Top
New
Controversial
Old
Q&A
To just avoid a stutter, use the ResourceLoader singleton, it has options for threaded loading. Put a bigger trigger around your loading trigger that signals to start the loading process before the player actually reaches the loading zone.
I would never use the change scene commands, I would create a Main scene that has a World node which actually contains the level scene as the sole child, and I would queue_free its child and replace it whenever the level should change. Transition zones would emit a loading_zone_entered signal the World node (and anything else that needs to know the level is changing like the transition effect) is listening for either directly or through an event bus, along with the destination level name. World can look up the level and load it normally at that point either through the filesystem using the level name as a filename, or a dictionary associating level names to file paths. If your transition effect has a point at which you can afford to block the main thread, like a totally black screen, and your scenes are small enough to load basically instantly, you might not even need to do threaded loading. With threaded loading and zones that trigger when the player clearly intends to do something that requires loading, nothing unnecessary is in memory and you should never block the main thread so long as the threaded loading trigger was big enough to give the file enough time to load.
https://docs.godotengine.org/en/stable/tutorials/io/background_loading.html
track me
Great explanation, thank you! I like the approach you're taking, I will try this out.
See Singleton(Autoload) example Custom Scene Switcher. https://docs.godotengine.org/en/stable/tutorials/scripting/singletons_autoload.html#custom-scene-switcher
This is the pattern to solve your issue.