+1 vote

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?

in Engine by (664 points)

2 Answers

+3 votes
Best answer

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.

by (20,677 points)
selected by
0 votes

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

by (44 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 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 webmaster@godotengine.org with your username.