extends Node2D
var enemy_counter
@onready var path: PackedScene = preload("res://scenes/enemy_path.tscn")
func _ready():
pass
#print(EnemyAutoload.level)
func _process(delta):
pass
func _on_timer_interval_timeout():
$TimerSpawner.start()
enemy_counter = 0
print(EnemyAutoload.level)
EnemyAutoload.level += 1
if EnemyAutoload.level >= 3:
EnemyAutoload.level = 0
func _on_timer_spawner_timeout():
var temp_path = path.instantiate()
add_child(temp_path)
enemy_counter += 1
#print(enemy_counter)
if enemy_counter == 3:
$TimerSpawner.stop()
$TimerInterval.start()
Another gd script
extends PathFollow2D
@onready var enemy1 :PackedScene = preload("res://scenes/enemy_1.tscn")
@onready var enemy2 :PackedScene = preload("res://scenes/enemy_2.tscn")
@onready var enemy3 :PackedScene = preload(("res://scenes/enemy_3.tscn"))
func _ready():
enemy_level()
func _process(delta):
pass
func enemy_level():
var enemy1_temp = enemy1.instantiate()
var enemy2_temp = enemy2.instantiate()
var enemy3_temp = enemy3.instantiate()
match EnemyAutoload.level:
0:
add_child(enemy1_temp)
print("add_child(enemy1_temp)" + str(EnemyAutoload.level))
1:
add_child(enemy2_temp)
print("add_child(enemy2_temp)" + str(EnemyAutoload.level))
2:
add_child(enemy3_temp)
print("add_child(enemy3_temp)" + str(EnemyAutoload.level))
_:
print("default")