I was using the wrong node to select from, the signal is on the note_hitter not the note itself…
Question
I have a node defined as the following
#name: K_note_hitter
extends Node2D
...
signal hit_signal(hit_score)
which I try to connect in a parent that instantiates it as follows
*Correction: signal was from a different node
#name: RhythmStage
func _ready():
#Correct place to get signal
note_hitter.connect("hit_signal", Callable(self, "on_hit_signal"))
A_path.add_child(K_note_scene.instantiate())
var a_notes = A_path.get_children()
for note in a_notes:
note.add_to_group("K_notes")
#Error - note doesn't have that signal, it's on note_hitter
note.connect("hit_signal", on_hit_signal) <-- ERROR
return
I get the error “hit_signal” is nonexistent. Even printing the signals or script.source_code doesn’t show the signal defined on K_note_hitter
(testing it in _ready() but this is going to happen repeatedly in _process())
I have also tried note.hit_signal.connect(on_hit_signal) to no avail.
What am I doing wrong?
note.get_signal_list() doesn’t list my custom signal
Could you try
note.connect(“hit_signal”, Callable(self, “on_hit_signal”))
If it doesn’t work - add print statements here and there to see what happens along the way and where it goes wrong
E 0:00:01:184 rhythm_stage.gd:23 @ _ready(): In Object of type ‘PathFollow2D’: Attempt to connect nonexistent signal ‘hit_signal’ to callable ‘Node2D(rhythm_stage.gd)::on_hit_signal’.
<C++ Error> Condition “!signal_is_valid” is true. Returning: ERR_INVALID_PARAMETER
<C++ Source> core/object/object.cpp:1526 @ connect()
rhythm_stage.gd:23 @ _ready()
If you want context: It’s a rhythm game where nodes flow down a path to get hit, this hit signal would emit a score of how accurately the hit was timed.