|
|
|
|
Reply From: |
Thomas Karcher |
It doesn’t violate the concept, and you can still inherit from the custom node script instead of changing it directly or replacing it: Just right-click on the newly added Unit and select “extend script”. The newly created script will start with something like
extends "res://Unit.gd"
and you will be able to use all functions of Unit.gd plus whatever you add in your extension.
Hmm, a little confusing. The main thing is that it works.
Okay, thanks a lot, tovarishch!
One more question.
I want to make several child plugins on the basis of my “unit” plugin, for example “player” and “enemy”. How do I add child classes to the hierarchy so that they appear as inherited from the “unit” class?
Of course, I can leave them in the “kinematicbody2d” branch, but I would like it to be beautiful
func _enter_tree():
add_custom_type("Player1",
"KinematicBody2D",
preload("res://addons/player1/player1.gd"),
preload("res://addons/unit/ico_unit.png"))
I never tried it, but shouldn’t it be enough to assign “Unit” as base node, like so?
func _enter_tree():
add_custom_type("Player1",
"Unit",
preload("res://addons/player1/player1.gd"),
preload("res://addons/unit/ico_unit.png"))
Thomas Karcher | 2020-12-17 14:32
Alas, it doesn’t work. I tried to prescribe different options, but nothing helps((
Thank you very much! I will try!