queue_free() not running even though the function is being called

Godot Version

4.3

Question

I have been having trouble getting this apple object to delete itself when exits the screen. I know the function is running since the test print is working. also the reason that they are two separate functions is that the apple will also eventually be deleted on contact with something else so it makes sense for it to be a separate function

extends Node2D
func _process(delta: float) -> void:
	position.y += 500 *delta


func _on_visible_on_screen_notifier_2d_screen_exited() -> void:
	apple_kill()
	
func apple_kill():
	print("test")
	queue_free()

How do you verify that the apple object has not been destroyed?

3 Likes

I was misunderstanding how the Remote tree view was working. I though upon queue_free being run it would remove it from the child from the remote tree view but upon testing using a timer to queue_free() so I could see it happened I realized it was not removing the children even upon beign removed. So it was working I was just misunderstanding stuff

1 Like

To be clear, it removes it at the end of the current frame.

Also note that remote scene tree view doesn’t update in real time. By default it updates every second. You can change this in editor settings: Run > Debugger > Remote Scene Tree Refresh Interval

1 Like