Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Daniel Mircea | |
Old Version | Published before Godot 3 was released. |
I have the following code structure:
# base-player.gd
func _init(arg1, arg2):
pass
# human.gd
extends "base-player.gd"
This works okay:
const PLAYER = preload("res://base-player.gd")
func do_stuff():
PLAYER.new("a", "b")
However the next snippet does not:
const HUMAN_PLAYER = preload("res://human.gd")
func do_stuff():
HUMAN_PLAYER.new("a", "b")
It raises Invalid call to function 'new' in base 'GDScript'. Expected 0 arguments.
.
But if I were to do HUMAN_PLAYER.new()
it raises Invalid call to function '_init'. Expected 2 arguments.
.
Why is this happening? What’s the proper way of doing inheritance of basic scripts?