Adding Enemy at Event

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Rayu
func _ready() -> void:
    for i in range(3): 

func _on_sprite_pressed():    <--- Event
    Score += 1
----> spawn a new Enemy <----

func spawn_enemy():
	var rand2 = floor(rand_range(0, Enemy.size()))
	var piece2 = Enemy[rand2].instance()

This is my Code.
With Every Event there comes a new Scene and with a new Scene i want that a new Enemy is spawned.
I want that the Enemycount is the same with the Score. ( if Score is 10 = spawn 10 new Enemies)

Can someone please help :confused: ? with Codes if possible :S

:bust_in_silhouette: Reply From: rballonline

Why aren’t you just calling spawn_enemy where you have ----> spawn a new Enemy <----.

If you want Score amount of enemies to spawn, then put in a for loop to spawn a new enemy.

for i in range(Score):