How to make a proper transition when loading scene ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mbenoni
:warning: Old Version Published before Godot 3 was released.

Hello guys !

I’ve a question there :

  • How to make a proper transition when loading scene ?

I explain:

Currently , I have a “RootScene” with a Script. In this script, in the _ready() function, I load 4 big scenes, then instantiate them and stock them in my Script’s var.

Then, I just have to add_child() or remove_child() theses instances in my script to switch between the 4 scenes efficiently and without any loading time.

But then, a problem occurs : Because my scenes are huge, The game take some time to launch. And, obviously, more and more as my scenes grown bigger and bigger.

In order to have something more “clean”, I made a “launcher screen”, a little animation scene, which launch when opening the game (and so the game open really fast, as the scene is really little). And next, after the animation, i wanted to switch to my RootScene.

But, obviously, the time that was previously used to launch the game is now used between my LauncherScene and my RootScene.

So I wanted to make something like a “progress bar” as a transition between my two scenes, for having something “fluid” instead of waiting face to face with a black fixed screen.

I’ve read Background loading — Godot Engine (stable) documentation in English but it doesn’t seem to work, so I ask myself how can I do this ?

Just a comment, if your scene is too big but does not need everything loaded right away, you can use instance placeholders and load only the immediate and the rest while running.

InstancePlaceholder — Godot Engine (stable) documentation in English

eons | 2017-04-27 16:53

why is the background loading as described in that link, nor working ?

MrMonk | 2017-04-30 17:09

Not sure, the way you load/preload the scenes and the scene structures may affect it.

eons | 2017-04-30 19:33

:bust_in_silhouette: Reply From: mbenoni

Hello !

So, it seems I had misunderstood how the “background loading” works.

In fact, when doing background loading on a scene as the tutorial shows, it does, but ONLY for this specific scene load.

I explain.

Imagine we have this structure :
“HelloLogo.tscn”
– load “Root.tscn” (2 fragments in a loader)
---- load “Subscene1.tscn” (7 fragments in a loader)
---- load “Subscene2.tscn” (8 fragments in a loader)
---- load “Subscene3.tscn” (4 fragments in a loader)

In this case, HelloLogo load Root, and Root load the three subscenes.

If you do background loading in HelloLogo to load Root, it will ! But it will ONLY fragment Root. Not the subscenes. So you will have only, like, 2 steps (which is fairly useless for a progress bar, yep ?). Then Root will load normally his subscene, and it will freeze.

To have it work correctly, you must do the BackGroung loading in Root for the subscenes, in my case. That means, load Root from HelloLogo, and then in Root, background load all subscenes in order to have (7+8+4 = 19) fragments, which is a better progress bar, and will have no freeze.

If anybody has a clue about a “backgroundloading” that fragment also Subscenes from the loaded Scene, however, that could be really helping for other cases. But I doubt it exists.

can’t you preload all subscenes into the ready function of the root node ?

MrMonk | 2017-05-03 14:03

:bust_in_silhouette: Reply From: VitaZheltyakov