Step by Step loading of scene

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

Hi godot developers,

I m new to godot and get some knowledge from docs.
I want to reduce loading time of scene by step by step loading nodes as player moves. I think that can be done with _enter_tree and _exit_tree but i dont know how to use them.
Anyone godot developer help me out of this.

Thankyou

_enter_tree and _exit_tree are signals occurred when node is added to scene tree.
I think it cannot be done with this signals.
try to using Area or Area2D nodes.

volzhs | 2017-08-09 14:08

:bust_in_silhouette: Reply From: eons

You will need to design some trigger structure (like areas) stick to the player or the camera and others areas on the points where the new nodes should be loaded.

When the trigger hits one, the scene loads that part (updating what it need), the same to remove them (and save the state) if needed.

Of course, those sections should be (preloaded) scenes as well.

How to create that structure depends heavily on the game design (more than the engine used).


There is an option in the editor to turn scenes on the tree into “instance placeholders”, that turns the node into a InstancePlaceholder that delays the instantiation until you trigger, but there is no reverse process (you can’t turn scenes into placeholders) so is only useful for loading things once.

Visibility enablers/notifiers are good to control process, if your scenes are not too big, you can “pause” things far from view without the need of removing them (these could be used as a previous step to removing too).

Hi eons,
I like ur answer but I not get that “full” as I m new to Godot.
I wanna ask that if I can do this by dot product…if I get to certain region, nodes load cause I want to create a single stage game in which at every stage we save the game state and it might take much loading time to load a scene or stage fully that way…so I want scene to be loaded in field of area (in subscenes) of player 2 subscenes forward and 1 backward.
If u got me this I would be very thankful.
Thankyou

gulatihardik10 | 2017-08-10 05:45

I don’t understand how “dot product” can help you with this.

I think (for the description) that you want to do some background loading of parts of a big scene, so dividing your scene into many sub scenes and using the “instance placeholder” option (with a thread that instance them one by one) should be enough.


Here is an example of a generic background loading, this could be combined with the placeholder option
Background loading — Godot Engine (stable) documentation in English

eons | 2017-08-10 22:27

Hi eons,
Thanks for ur reply, I understand what u mean and will do that in my project.
But can u tell me how to dividing scene into subscenes. I might think I have to read docs again so that my many queries get resolve. Thank you again for ur precious time.
Thankyou

gulatihardik10 | 2017-08-11 07:07