How to pass argument to signal

im getting an error Cannot call method 'queue free' on a previously freed instance.
this is my spawn function:

func spawn_object():
	var obj_inst = obj_spawn.instantiate()

	if get_node_or_null(spawn_target_node) != null:
		if obj_inst is Node2D:
			obj_inst.global_position = self.global_position

			get_node(spawn_target_node).add_child(obj_inst)
			my_obj_count += 1
			spawned_object = obj_inst
			print("enemy spawned")

			if enable_respawn:
				if not obj_inst.is_connected("tree_exited",  Callable(self, "_on_my_spawned_obj_exited")):
					obj_inst.connect("tree_exited", Callable(self, "_on_my_spawned_obj_exited"))

func _on_my_spawned_obj_exited():
	if can_respawn == true:
		my_obj_count -= 1
		can_respawn = false
	#can_respawn = false
	print("reset obj count")

func free_enemy():
	spawned_object.queue_free()

never mind, i solved the problem. All works perfectly. Thank you so much for help everyone!
I wonder how long it would take me to come up with my own idea to solve my own problems…

1 Like

Experiences will come up as you go further in programming. I had been struggling with stressful issues, and my skills grew stronger as I solved these problems. I often think that it’ll be faster and easier to skills up if I have such a forum. But the reason that most matters is this is a gift of God, and He really blessed me.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.