.connect() Object to Callable issues

Change

    pickcollision.connect("tilemap_entered", self, "_on_tilemap_entered")
    pickcollision.connect("tilemap_exited", self, "_on_tilemap_exited")

into

    pickcollision.connect("tilemap_entered", _on_tilemap_entered)
    pickcollision.connect("tilemap_exited", _on_tilemap_exited)

The former is how it worked in Godot 3, the latter is how you connect a signal in Godot 4 now.


The error message tells you, you’re using a function (in this case connect) that expects a certain type (Callable) as its second argument, but what you gave it (self, of type Object) cannot be converted to it, thus is considered invalid. In other cases (e.g. when passing an int to a function that expects a float) that conversion would be possible and then carried out automatically by the Engine.

1 Like