+3 votes

What is the difference between parents and owners?

in Engine by (652 points)

2 Answers

+4 votes
Best answer

This is what I can get from the docs.

  1. A node's parent is a node that is one level up the node's hierarchy.
  2. A node's owner is one that the node will be saved along with. Eg: If you make a node from script in the editor, it will have a default owner of null. Therefore it won't be saved with the currently edited scene.
by (3,857 points)
selected by

I was just answering the same.

+2 votes

Hi,

Parent is the direct node above in hierarchy in your tree structure. For example, in the next tree:

->Node2D
--->Area2D
--->KinematicBody2D
------>AnimatedSprite

Node2D is parent of Area2D and KinematicBody2D, and KB2D is parent of AnimatedSprite.

Owner instead can be any node that is parent or grandparent etc. It is useful for packed scenes, for exampling in saving nodes at runtime. When you want to save a node, all the nodes it owns get saved also, but no the children it does not own. Also, from docs:

To keep track of the scene hierarchy (especially when instancing scenes into other scenes), an “owner” can be set for the node with set_owner. This keeps track of who instanced what. This is mostly useful when writing editors and tools, though.

Parent wont do in this case.

by (3,382 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.