Thanks sir it surely makes the enemies appear differently now but I was wondering if I could do something that will make the enemies appear after a long time. For example I want to do something like this, make the first enemy appear when the game starts then make the second enemy appear after 15 seconds or so. I tried using a TIMER but it seems like _ready()
ignores the timer and hence my timer isn't working. here's the code
func _ready() -> void:
spawnEnemy1()
$EnemySpawnTimer.start(20)
_on_EnemySpawnTimer_timeout()
func spawn():
while true:
yield(get_tree().create_timer(rand_range(1.25,3.00)),"timeout")
randomize()
var enemy = enemy1.instance()
var pos = Vector2()
pos.x = rand_range(0+16, get_viewport().get_visible_rect().size.x-16)
pos.y = 0-16
enemy.set_position(pos)
get_node("Container").add_child(enemy)
func _on_EnemySpawnTimer_timeout() -> void:
spawnEnemy2()
I also tried making a counter that will count how many enemies I have killed and then spawn the other enemies. For that I added a variable in the global script but in my _ready()
if I do something like this :
func _ready() -> void:
spawnEnemy1()
if global.enemykillCount > Any value:
spawnEnemy2()
the if statement never executes for some reason.