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

i'm wondering if when you extend from super-classes, the node the script is attached to becomes an instance of the subclass the script represents. or maybe it's just some separate object that is paired with the script in some way?

Godot version 3.4
in Engine by (65 points)

Not entirely sure but your question is a really good topic to open up for discussion so if you haven't already also include it in the Godot forums.

My money is on your first suspicion as you can extend in reverse of the node tree and lose all of the current class's implantations yet never future version of that same node.

if base node is Control

extend Node 
# works
# no Control members like rect_position
# instance becomes Node in sceneTree

extend Button #fails

Understand your confusion like shouldn't a node be whatever a script tells it to be?

Honestly it's best to avoid the whole Node paradigm and use Class Reference instead only extending a node when you need Node specific behavior or visual representations

1 Answer

0 votes

I have the same question.

I always assumed a script 'augments/customizes' the node it's attached to, but that they are basically the same thing. However, when you mark a script as 'autoload' a new node is created in the senetree (you can see this in the 'remote tree' when you run the scene). This new node has the same type as the script, but it is -not- the node the script is attached to ...

I wondered if you have more information on this now ?

by (101 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.