Inherit scene that contains another base scene child

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By gd_question

I have a scene A-BASE with child B-BASE. I want to inherit A-BASE and change the child to B-DERIVED in the new A-DERIVED. Is it possible?

I don’t think you can change the node types (from the child of type BBASE to BDERIVED) in the scene tree of an inherited scene.

Depending on your goal, you might be able to achieve what you want to do by using script inheritance instead of scenes, and dynamically remove and add scripts of the prefered type.

Also, what you could do is have a scene ABASE, then define two inherited scenes, ADERIVED1 that has the child scene BBASE, and ADERIVED2 that has the child scene BDERIVED. Although this proposition might not meet your requirements.

godot_dev_ | 2022-07-20 16:28

When using script inheritance you loose the adventage of visual editing. And my scenes are more complex than the example in the question, so it will be a lot of code.
As for the second proposal you loose the polymorphism, since ABASE don’t have BBASE child. And again you loose the advantage of visual editing, since you have to set all the relevant properties of BBASE children in every derived scene.

gd_question | 2022-07-20 17:00