Total game dev newbie here! I am trying to set up an exp system, the same as Vampire Survivors where enemies drop exp gems. My problem is when I queue_free() / kill the enemy, it does not spawn (and or call the function to spawn) the gems that I instance in which I do in a function that I call on my bool is_dead being true (is_dead also calls queue_free(), to clarify). I am using GD Script btw. Thanks in advance!
func summon_exp():
var EXP = preload("res://Scenes/exp.tscn")
var new_exp = EXP.instantiate()
new_exp.position = position
add_child(new_exp)
func _on_animated_sprite_2d_animation_finished():
if is_dead:
summon_exp()
queue_free()
Since EXP is added as the child of the enemy, when the enemy is destroyed, the exp will be destroyed with it.
So you can try to put the exp on the parent of the enemy or somewhere else.
Awesome, this worked for me. Seems I need to spend some more time reading the documentation… Anyhow thanks for the help! I was stuck on this for an embarrassingly long time