0 votes

Hello, I have a problem when I say in my script

var object = preload ("res: //scene/object.tscn") .instance ()

and the object is duplicated.
then everything loads perfectly, but my scene contains a signal, to be precise a button signal.
If I press the button then the output shows an error:

E 0: 00: 04.882 emit_signal: Error calling method from signal 'pressed': 'Node2D (tree.gd) :: _ on_Button_pressed ()': Method not found ..
   <C ++ source code> core / object.cpp: 1260 @ emit_signal ()

this cannot then be carried out.
Does anyone know what I mean and what I can do?

Thanks in advance

Godot version 3.2.3
in Engine by (85 points)

Does the method exist on the object you are running .instance() if not, you may have to make the signal connection in code. For example, if you have a main scene instancing enemies and those enemies have signals that need to call the main scene's methods, you can connect the signals to the main scene when it creates the enemies. Check out connecting signals in code.

2 Answers

+1 vote
Best answer

In the signal connection for the button (in the editor), is the function name correctly written out? Note how the error prints out the function name _ on_Button_pressed ().

by (2,058 points)
selected by
+1 vote

The function referenced in the .tscn file is not defined in the .gd file.

What do you mean by:

"... the object is duplicated."

It would be fastest if you can you share the two files here so we can be more helpful.

by (58 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.