Nonexistent signal on instantiated node

Godot Version 4.5

Solved:

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

print(note)

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

K_note:<PathFollow2D#36373005732>

that’s from print(note) - its the top level node’s name & where the script containing the custom signal is attached

What’s the exact error message?

Same issue, I think it comes from not being able to discover the signal on K_note

Here is the output to new_note.get_signal_list:

draw
visibility_changed
hidden
item_rect_changed
ready
renamed
tree_entered
tree_exiting
tree_exited
child_entered_tree
child_exiting_tree
child_order_changed
replacing_by
editor_description_changed
editor_state_changed
script_changed
property_list_changed

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.

print(note.get_script().source_code)

Why is script extending Node2D but is attached to PathFollow2D?

There are 3 objects (scripts):

  • Stage (node2D): parents everything, instantiates new_notes - should receive hit_signal so it can update UI
  • note_hitter (node2D): sits at the end of a path, checks for areas (notes) on its selected input key - contains hit_signal
  • note (pathFollow2D): simple object with areas, is moved across path by stage

Apparently, note doesn’t have that signal declared.

omg, wrong thing to connect from… updating post

it’s a signal coming from the note hitter not the note… LOL

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.