This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I have lots of instances of a node that I want to delete themselves when they enter an area.

The initial node that I have on the screen deletes itself fine but its instances do not (even though they are all being detected by the area). I've tried lots of stuff from the forum but I can't figure it out.

In my code it's known as sugar, and the area is known as bin. I've tried things like sugarinstance.instance().queuefree() but i can't get it to work. Thanks in advance.


Extends Node2D

onready var sugar_instance = preload("res://sugar.tscn")

func _process(delta):



func _on_bin_area_body_entered(body):

    print("Entering bin")
in Engine by (15 points)

1 Answer

+1 vote
Best answer

Have you tried

by (4,246 points)
selected by

Works perfectly, thanks so much.

Can I ask what this does and why this works? And why queue_free() doesn't?


Just queue_free() will free the node attached to the script, in this case - bin_area. But body.queue_free() will free the body entering the bin_area. You simply called queue_free() on the wrong node.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.