|
|
|
 |
Reply From: |
jgodfrey |
I don’t think your problem is on the emit
side of the signal. It’s likely on the the receive
side. So, somewhere you’re receiving the connected2
signal, which will have been defined something like:
connect("connected2", self, "my_function")
Whenever the connected2
signal is received, the above will attempt to call a function named my_function
. I’d guess you don’t have that function defined (named whatever you called it in the connect
function).
If that doesn’t help, post the connect
side of the signal.
Here’s the connect section.
func _on_Area2D2_connected2():
isConnected = true
User457654654 | 2020-06-12 19:30
But your connected2
signal is a custom signal, right? In that case, somewhere, you should have a statement similar to the one I posted above that actually connects a listener to that signal. Again, that should be something like:
connect("connected2", self, "my_function")
Do you have such code in the script that’s designed to receive the signal?
Also, post the full error so we can see the name of the missing method.
jgodfrey | 2020-06-12 19:38
This code, correct?
func _ready():
connect(“connected2”, self, “Area2D”)
I get this:
E 0:00:02.180 emit_signal: Error calling method from signal ‘connected2’: ‘Node2D::_on_Area2D2_connected2’: Method not found…
<C++ Source> core/object.cpp:1228 @ emit_signal()
Area2D.gd:22 @ _on_Area2D_body_entered()
I also get:
E 0:00:02.189 emit_signal: Error calling method from signal ‘connected2’: ‘Area2D(Area2D.gd)::Area2D’: Method not found…
<C++ Source> core/object.cpp:1228 @ emit_signal()
Area2D.gd:22 @ _on_Area2D_body_entered()
User457654654 | 2020-06-12 20:18
Yes, that’s what I’m looking for. In that connect
code you posted, you’re basically telling that script to listen for the connected2
signal, and when it’s received to call a function named Area2D
- also found in the current script.
That 2nd error you posted is saying that the script does not have a function named Area2D
- which I assume is correct.
That 1st error indicates that a 2nd script is also listening for the connected2
signal, and when it’s received, it’s trying to call a function called onArea2D2connected2
- which also doesn’t exist.
In the original code you posted, it seems like you’re expecting to call _on_Area2D2_connected2
when the signal is received, but that’s not what you defined in the connect
code.
Again, according to the errors, it’s looking for a script named Area2D
from one place and a script named onArea2D2connected2
in another.
Though, I think the underscores in those function names are causing some rendering trouble here in the forum. Posting the errors inside code tags would fix that…
Bottom line, find your connect("connected2", ...
statements (there are at least 2) and see what the 3rd argument to the is. That’s the method that will be called when the signal is received. If that method doesn’t exist (as in your case), you get the errors you reported.
jgodfrey | 2020-06-12 20:41
Darn… Apologies, I’m still new. I think I had a bug in a node so I replaced and fixed it. I am down to one code that has issues now, and each signal has one method not found.
extends Node2D
export var my_bool1 = false
export var my_bool2 = false
func _ready():
connect("connected1", self, "_on_Area2D2_connected1")
connect("connected", self, "_on_Area2D1_connected")
# warning-ignore:unused_argument
func _process(delta):
if(my_bool1 == true and my_bool2 == true):
$OtherArea2D.hide()
func _on_Area2D1_connected():
my_bool1 = true
func _Area2D2_connected1():
my_bool2 = true
User457654654 | 2020-06-13 00:31
So, if that’s your code, you still have a function name mismatch. Notice that you’re trying to connect to a function named _on_Area2D2_connected1
but the actual function name is _Area2D2_connected1
.
Note, one has a leading _on
and the other doesn’t…
I don’t see a problem with the other function as the names appear to match…
jgodfrey | 2020-06-13 00:50