Method not found error

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Syl


Here’s the trouble: I’m tryin to change scene after a click on a polygon2D and an animation, but it won’t be loaded, as I get that error message:

'0:00:14:0229 - Error calling method from signal 'input_event': 'CollisionPolygon2D(': Method not found.
Time: 0:00:14:0229
C Error: Error calling method from signal 'input_event': 'CollisionPolygon2D(': Method not found.
C Source: core\object.cpp:1202
C Function: Object::emit_signal

The weird is that I got two others collisionpolygon2D with same scripts, signals and animations workin perfectly well. Here’s the screenshot:

Imgur: The magic of the Internet With soulpoly bein my unefective collisionpolygon2D.

Renamed, formatted and tagged post

Zylann | 2018-03-09 13:49

Do you have a function called _on_Area2D3_input_event on (which is basically what the error is about, can’t guess more even with the screenshot)

Zylann | 2018-03-09 13:51

Yes, here’s the full script:

extends CollisionPolygon2D

func _on_Area2D_input_event( viewport, event, shape_idx ):
	if event is InputEventMouseButton:
        if event.get_button_index() == BUTTON_LEFT and event.is_pressed():
func _on_AnimationPlayer_animation_finished( change ):

But I got exactly the same with mindpoly and bodypoly, and that works perfectly…

Syl | 2018-03-09 13:56

:bust_in_silhouette: Reply From: volzhs

you connected input_event with _on_Area2D3_input_event
but you declared _on_Area2D_input_event.
look carefully, function name is different.

That’s it… Didn’t thought about that name…
Big thxs! :slight_smile:

Syl | 2018-03-09 14:53

:bust_in_silhouette: Reply From: jarlowrey

For me the issue was a mismatch between the parameters being passed and the parameters being used in the function observing the signal. In C# at least, I got this error.

Once I added the required parameters to the function it worked!

This solved for me. For example, public void OnAreaEntered() should be public void OnAreaEntered(Area2D area)

eduardocopat | 2022-03-23 03:50