Hello there friends.
I have an object that is shooting (instancing) projectile objects and its working fine.
I am trying to use remove_child()
to free any projectile that is instanced after the enemy dies so the projectile doesn't just vanish (the projectile can free itself just fine, made sure of this first). A bool flips when a projectile is fired and I've tried checking this but the bullet still disappears after the enemy is freed. Not getting any errors in the debugger either. I should note that the "EnemyBullet" is instanced from the enemy so hence the "if" to check if it exists before running.
Code seems simple enough. What am I missing?
func _exit_tree():
var _orphan = get_node("EnemyBullet")
if _orphan:
remove_child(_orphan)