How can I override a parent classes default variable? Some Control types for example override the stretch type and other default values of their parent class (the basic Control Node). They are highlighted in yellow in the local documentation.
How can I make my own class which for example inherits from CharacterBody3D and has a default position of vec3(0.0, 1.0, 0.0)?
The character body is just an example, I just wanna know how to override defaults.
I think you can’t override any defaults of a parent class. But I think that is a general thing with object oriented programming. If you want to dive deeper into object oriented programming in godot with abstract, virtual, … classes i advice you to use the .net version with c#. I hope that helps.
Maybe a bit late to the party, but I wanted to do the same and the only way I found to do this is to write a constructor for the child class (_init method) which does only 2 things:
I’ll explain a bit more the code above. From my tests, it seems that:
“loaded“ (n23 == 0) is only triggered when the node is created from memory, so when loading a scene either at runtime or in the editor.
“duplicated“ (n23 == 1) is only triggered when duplicating a node in the editor.
“created“ (n23 == 2) is triggered by creation within the editor, and creation only.
It’s just a weird thing using the number of NOTIFICATION_PATH_RENAMED signal triggered since the node was created. But somehow it works. I won’t question it.
And the “23“ everywhere comes from the int value of NOTIFICATION_PATH_RENAMED
Then he pairs that with the regular _property_can_revert and _property_get_revert to define defaults on the fields from the parent class.
Edit 3: I just noticed that it triggers code before you even get to `_enter_tree`, so in order: