Hello!

First post but long time lurker. I think my question is fairly basic, but it seems I might be confusing scene instancing and inheritance. Let's say I have a Planet scene with a Marker node in it, which is an instance of a scene with its own children. Now, to specialize the behavior of the Marker, I add child nodes to it, each responsible of a tiny feature. Composition is good, right? Well, if I have another scene, say, GasPlanet, that inherits from Planet, is there a way to modify a child of GasPlanet's Marker while keeping the ability to propagate changes made to other properties of the base Marker scene, to its instances?

I thought the whole point of inheritance was to allow overriding certain properties while keeping the others connected to and updated with the base's. Is my use of child nodes to specialize the parent illegal? If my setup is wrong, what would be the preferred way to organise scenes and nodes so as to maintain modularity and value propagation?

I know of Editable children of course, but checking it immediately breaks the connection and turns all properties red, which concerned me. I looked up 3.2.1's source and tracked that feature down to inspector_editor::update_tree() line 1494, which is so simple that it suggests the break-up is inevitable.

Apologies if that got long-winded. Many thanks!

I realize just now that Programming might not be an appropriate category for this question. Oops.

@pgig said: Hello!

First post but long time lurker...

Welcome to the forums! :smile:

I thought the whole point of inheritance was to allow overriding certain properties while keeping the others connected to and updated with the base's. Is my use of child nodes to specialize the parent illegal? If my setup is wrong, what would be the preferred way to organise scenes and nodes so as to maintain modularity and value propagation? I know of Editable children of course, but checking it immediately breaks the connection and turns all properties red, which concerned me. I looked up 3.2.1's source and tracked that feature down to inspector_editor::update_tree() line 1494, which is so simple that it suggests the break-up is inevitable.

It should be doable. Inheritance keeps all the same variables, functions, etc, but lets you add additional code on top, in addition to allowing you to override functions defined in the base class and the like. If I am understanding what you are describing correctly, then I do not think there should be too much of an issue using children nodes and inheritance, as long as the interface (functions, variables, etc) between the node and its children stays consistent.

With the connections, do you mind explaining the issue in a bit more detail? Are you meaning connecting signals? If so, I would suggest connecting the signals in code if you can, as then whether the node is inherited or not shouldn't change the connection code (so long as the function that connects the signals is not overridden).

@pgig said: I realize just now that Programming might not be an appropriate category for this question. Oops.

I thinks it probably fine, but if you have a different category in mind, please let me know and I'll move it to that category for you :smile:

It should be doable. Inheritance keeps all the same variables, functions, etc, but lets you add additional code on top, in addition to allowing you to override functions defined in the base class and the like.

My bad, I figured I wasn't clear. My question relates to editor use mostly, not programming per se... hence my follow-up self-reply. :)

By inheritance, I meant scene inheritance, rather than gdscript class inheritance. The dual usage is confusing indeed.

Here's my partial scene setup, not exact but close enough for the demonstration:

Marker --ShapeGenerator ----properties: edge_count, radius


Planet --Marker (instance of Marker)


GasPlanet (inherits Planet) --Marker (from Planet, editable children checked) ----ShapeGenerator (properties red!) ------modify edge_count ------keep radius from base Marker, want it to update if base Marker's is changed

And here's a whole novel putting it into way too many words:

So I have a scene, Planet, that has (among others) a child node, Marker, instanced from the Marker scene, with children added to it to specialize it (DistanceFader, ShapeGenerator, MarkerAnimator, etc).

GasPlanet inherits from Planet (from File/New Inherited Scene...) . My issue is that if I want to modify one of Marker's children (say, ShapeGenerator, to change its shape, but it could be the animation, etc) in GasPlanet, I need to expose the former in the editor using "Editable children". However, by doing so, all properties of Marker turn red, which I understand to mean that they will not be updated if the base scene, Planet, is changed, even if they weren't modified (again, in scene instance). So if I change the default color for all Markers, for instance, the change will not be reflected in GasPlanet's Marker. (Planet's Marker is irrelevant here because it isn't modified from Marker's defaults)

That's what I meant by "losing connection" - a bad wording considering the accepted relation with signals.

And that's what I'm trying to do: change a property of a child of Marker in GasPlanet while also having the others update if the child in Marker's base is modified, or in the Marker in Planet, etc.

The gist of it, really, is that I want to check "Editable children" to change a property while having the others update with their base values. Obviously it doesn't work like this and am wondering how others deal with this.

Dang, sorry. Hopefully this makes more sense, but somehow I'm not that convinced... :)

2 years later