#despawning enemies?
1 messages · Page 1 of 1 (latest)
wait so %enemyDespawn.start starts a timer? and then on timeout you want the enemy to dissapear?
so why not under on_enemy_despawn_timeout call queue_free on your enemy
since you just want them to disappear and be gone
i dont want it to despawn all the enemies, just the one that just got spawned
like enemy spawn, if 20 seconds go by and its not dead, despawn
enemies spawn in every 5 seconds, so i dont want them to all despawn once the 20 is up
okay, so the new enemy, new_mob, needs to be killed after 20 s got it
ill take a video of how the game is rn
is this the script for like an enemy spawner or does this go on each enemy?
ok so
if they make it to the other side of the screen, i dont want them to just live forever
i want them to despawn eventually
ig what i could do is put some area2Ds on the edge of the screen and if they hit that they despawn, but im just hoping for an easier solution
i gotcha. I feel like you could put a script and a timer on the enemy itself, in its scene, and then have the timer timout signal and queue free happen on each enemy instead of in this script.
however i still think it's possible to handle it in this script. But i would think you might need to create a new timer for each new enemy? otherwise yeah i don't know that this would work
but yeah i would put a function in the enmy script like start_despawn_timer():
timer.start()
_on_timer_timeout():
queue_free()
and then in this spawner script add under spawn
new_mob.start_despawn_timer()
that seems like it would work to me. Assuming what you have is not on the individual enemies
or you could actually just start the timer in the ready function of the enemy so it just happens by itself