How to make the scene change when all the enemies are killed?

Godot 4.3

I’ve been looking, and i can’t find anything to help me with this, does anyone know how to change scenes when all enemies in the current scene die?

CODE:

extends Node2D
var enemy_list = [$"chicken", $"chicken3", $"chicken8", $gateopener, $"chicken2", 	$"chicken4", 	$"chicken5", $"chicken6"]

func _process(_delta):
	if enemy_list.queue_free():
		get_tree().change_scene_to_file("res://scenes/game 	screens/barn.tscn")

queue_free() is a callable function that freed or remove any object from the scene. So you need to do this in another way like this:

if enemy_list == null:

or if it does not works then print it: print(enemy_list) in process and kill all enemies and then tell me its output at the last.

1 Like