What's the best way to extends a scene

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By alexzheng
:warning: Old Version Published before Godot 3 was released.

For example
We defined a base_enemy scene including some nodes, implemented some common behaviors in the script.

When it become to define specific enemies, how to share the common script and node from the base_enemy and modify or add some more behaviors.

It seems it can not extends a scene,.

It seems it’s a request feature requested by many users.
Will it be available in the 3.0 release?

alexzheng | 2017-04-06 11:51

:bust_in_silhouette: Reply From: Zylann

In 2.1.2 you can create a scene that inherits a base one by using Scene → New inherited scene.
Then you choose the base scene so you can start editing with it as a base (which is the same as having the root being a scene instance with editable children).

Thanks, this is almost what I’m looking for.
The nodes structure is inherited by this way, but the scripts are shared, to make a inherited script, I think it’s possible to extends the base script and attached to the inherited scene.

alexzheng | 2017-04-06 14:50

Yeah, you can extend a base script by using extends "res://path/to/script.gd" And then you can set this new script as the script for that new inherited scene.

CowThing | 2017-04-06 16:39