What's the difference between two load methods?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JulioYagami

I wanted to know if there is some difference between calling load() and instancing a node with the link button. And what’s the better way?

:bust_in_silhouette: Reply From: kidscancode

You are comparing apples and oranges.

load() loads a resource into memory. instance() takes a PackedScene resource and creates all of its packed nodes.

When you click the “link” button in the editor, you’re doing both, plus adding it to the scene tree.

Instancing in code versus the editor is the same thing in the end. One is not “better”, but they have very different use cases. Bullets, for example - you don’t instance the bullet in the editor, because then you’d only have one bullet there. Instead, you want to instance one in code every time the player pushes the “shoot” button.

:bust_in_silhouette: Reply From: CynicalKazu

load() literally loads resources into memory while instance () just creates an instance of a scene by retrieving it from memory.