#Issue with Custom Signal not Firing or not being received

1 messages · Page 1 of 1 (latest)

sturdy jacinth
#

Hey there, I'm new to godot but long time unity dev. I'm having an issue with implementing custom signals, I've followed both the documentation and 4 or 5 different video tutorials on youtube, but it seems not matter what I do I can't get the signal to go through. I'm not sure if it's emitting wrong or if what's supposed to receive it isn't receiving it (don't know how to check that in godot).

I have it hooked up via the Node signal UI using the Connect option. I've also tried connecting it via code, I get the same result either way.

Is there something obvious like certain data types can't use signals? The two scripts in question are using extends Node and extends Node2D.

I'm on Godot 4.3, I'm leaving out most of the code for simplicity sake, but here's what I believe is the only relevant code
MonsterManager:

extends Node2D
signal new_mon_created

func create_new_mon(monsterBreed : String):
  print("about to emit new mon created signal")
  queue_free()
  #emit_signal("new_mon_created") (tried both of these)
  new_mon_created.emit()

The above print line does fire.

MonsterTestUI:

extends Node

#At one point I tried connecting via code like so below, but right now it's #setup with the node signal UI in editor
#func _ready():
##$"../MonsterManager".new_mon_created.connect(_on_monster_manager_new_mon_created)  

func _on_monster_manager_new_mon_created():
    print("received new mon created signal") #this never shows up in the output

I really appreciate any help/guidance, been struggling with this for a few hours >.>

floral gazelle
#

why are you calling queue_free() before emitting the signal? seems like you'll just get rid of your monstermanager when you call create_new_mon()

#

(tiny nitpick but mosterBreed is in camelcase although gdscript params are usually in snakecase)

sturdy jacinth
floral gazelle
#

queue_free is the function you call when you want to free a node, so calling it there would just free the manager once you use it once :p

#

but honestly it should work with how you've set it up

sturdy jacinth
#

Dang I was hoping I was just missing something obvious lol

sturdy jacinth
#

Well, I'll just work around it and call the function from a node directly instead of using signals I guess unless anyone has other ideas. thank you for checking it out!

shadow socket
#

i tried replicating the situation with the code supplied (calling create_new_mon() in _ready()). The signal connection and prints (both connecting in editor and using your connect code) seem to work fine for me. There might be something else at play that i got cut out in this code, but idk what could be