I am creating a dispenser that should be able to spawn anything (enemies, power-ups, etc.)
Fo now, I have this code:
export(float) var delay: float = 1.0
export(PackedScene) var dispense: PackedScene
func _ready() -> void:
$Timer.wait_time = delay
func _on_Timer_timeout() -> void:
var newElement = dispense.new() # This doesn't work
func _get_configuration_warning() -> String:
if dispense == null:
return "%s needs an element to dispense" % name
dispense attribute is the thing that is supposed to be emmited every
How do I instanciate a new element based on its type? I tried
element.new(), but it doesn't work (Invalid call. Nonexistent function 'new' in base 'PackedScene'. when interpreted).
How do I instanciate it?