Topic was automatically imported from the old Question2Answer platform.
Asked By
rico345100
I connected signal when a scene is instantiated.
# AsteroidSpawner.gd
func spawn_asteroid():
var asteroid_instance = asteroid_scene.instance()
asteroid_instance.connect("destroy", self, "handle_asteroid_destroy")
add_child(asteroid_instance)
func handle_asteroid_destroy():
... # TO SOME STUFFS WHEN ASTEROID DESTROYED...
... # How to disconnect this handler from here?
But the problem is, I want to disconnect handle_asteroid_destroy handler when object destroyed(or will destroy, use queue_free). How do I disconnect signal on specific object? Is Godot Engine will free the handler automatically?
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:
@Eric Ellingson Thanks, however I want to make sure the handler was disconnected. I couldn’t find any related information about this, how do I get list of connected signal handlers?