@Iohanan said:
Well, If I wouldnt type this spawn script then my enemy (according to tutorial) should be just going down for eternity.
With the script, it should spawn enemies in different locations.
Actually, I wrote the script, and it's doing literally nothing, my enemy is still going down and no other enemies are spawning....
Where is the spawn_enemy
function being called? In the code shown so far, there isn’t anywhere that calls it and that might be why nothing is spawning. What you might want to do is add something like print(“spawn called”)
to the spawn_enemy
function to see if it’s being called from anywhere.
If the function isn’t being called anywhere, you could add some code to the _process
function to spawn enemy’s every few seconds for testing. Something like this:
# how many enemies to spawn per second
var enemy_spawn_rate = 1.5
var enemy_spawn_timer = 0
func _process(delta):
enemy_spawn_timer += delta
if (enemy_spawn_timer >= enemy_spawn_rate):
enemy_spawn_timer -= enemy_spawn_rate
spawn_enemy()
This method isn’t probably the most ideal, as it will just spawn enemies forever, which likely isn’t what you always want to do, but for testing the spawn_enemy
function it should work.