you'll need to save a reference to the asteroid in your AsteroidSpawner
var asteroid_instance
func spawn_asteroid():
asteroid_instance = asteroid_scene.instance()
asteroid_instance.connect("destroy", self, "handle_asteroid_destroy")
add_child(asteroid_instance)
but then its as simple as calling .disconnect()
with the exact same params called for .connect()
func handle_asteroid_destroy():
asteroid_instance.disconnect("destroy", self, "handle_asteroid_destroy")
However, I don't think you need to worry about doing this. I think this is only for when you no longer want a node to listen to a signal, not for cleanup which should be done for you.
Also, if you don't want to save the reference to the specific asteroid in the spawner, you can pass that along with the destroy
signal:
# Asteroid.gd
func some_function():
emit_signal("destroy", self)
then in your handle_asteroid_destroy()
function:
# AsteroidSpawner.gd
func handle_asteroid_destroy(asteroid):
asteroid.disconnect("destroy", self, "handle_asteroid_destroy")