Godot Version
4.2.1
Question
I have a probelm where I get the error
“Attempt to call function ‘queue_free’ in base ‘previously freed’ on a null instance.”
Been trying to debug this for hours now, there is no other place where queue_free() is called and I am pretty sure the error occurs because two instances of the NPC this function belongs to try to execute it at the same time. I tried to fix that by checking for “is_queued_for_deletion()” but that doesn’t stop it.
Does anyone have an idea what I might be missing or can explain why this still happens?
func _on_food_zone_body_entered(body):
if body is Fish and body.is_queued_for_deletion() == false:
current_state = WAIT
$CPUParticles2D.emitting = true
await get_tree().create_timer(2).timeout
body.queue_free()
$CPUParticles2D.emitting = false
elif body is Player:
current_state = FLEE
else:
randomize_wander()
current_state = WANDER