I’ve added multiple instances of a scene as enemies, and now I want to remove one of them when it dies. I tried using “queue_free()” on it, but this only works for one instance, and every instance afterwards doesn’t get removed and returns a “node not found” error. How do I just remove one instance at a time?
1 Answers
0
votes
Your question can't be easily answered because we don't know your specific code and there are multiple good ways to do this. As far as I understand you, you have an enemy class with some kind of health level. You could create a function that checks if the health is above zero or some other variable like alive. A very easy way would be like
func is_alive():
if health > 0:
return True
else:
queue_free()
You could call this function in every process cycle and also add some dying animation or counter later.