This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

My question does the resource loader just load a new scene inside another one, or does it act like the gettree.changescene function that completely changes your scene.

Godot version 3.3.3
in Engine by (20 points)

1 Answer

+1 vote

Answer

Loads a PackedScene in the background.

Load

Load() gets a PackedScene from .res, .tscn, .scn to be instanced however when used on large scenes or multiple scenes in succession a noticible game freeze can be observed.

#Usage
func _ready():
    var packed_scene = load("scene.tscn")
    var scene = packed_scene.instance()
    get_tree.change_scene(scene)

Preload

Same as Load() but does all the loading at game start instead. This works really well for small projects, not so much when you have 50+ scenes and your game takes forever to start.

#Usage
var packed_scene = preload("scene.tscn")

func _ready():
    var scene = packed_scene.instance()
    get_tree.change_scene(scene)

Background Resources Loader

This as the name suggests is more thread wise and prepares a scene for use while your game is doing something else (for example showing a video or ad or loading screen)

Clarity

All of the above do the same thing in different ways, give you a PackedScene.

It does not.

  • add the scene to the sceneTree
  • change the current scene
  • create an instance

Additional reading

Background Resources Loading

by (6,942 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.