connecting signal via editor does not work.

Godot Version

4.4.1

Question

I am new in godot. I try to connect a signal via editor but it doesn’t work and there was no error, but I found out that it ok to connect the signal via code. I am kind of confused.

How did you try to connect the signal in the editor? How did it not work? Did it appear connected but not signal? Did it not show the “connected” icon in the script window?

Sorry I accidentally post it without my code and pics. Here are my code and pic.

class_name HurtboxComponent
extends Area2D

@export var health_component: HealthComponent

func _ready() -> void:
	#area_entered.connect(_on_hurtbox_entered) # this work
	pass

func damage(attack: Attack):
	health_component.damage(attack)


func _on_hurtbox_entered(area: Area2D) -> void:
	print("hurtbox entered")
	print(area.name, " -> ", self.name)
	var weapon : Weapon = area
	self.damage(weapon.attack)
	var direction = weapon.global_position.direction_to(owner.global_position)
	print("direction:", direction)
	owner.velocity = direction * weapon.knock_back


It appeared connected. But when a weapon enter nothing show in output. And I disconneted it then use code to connect it, it worked correctly.

enemy using hurtbox:

player using weapon:

And game scene:

Check both Output and Debugger docks. If the signal is not correctly connected it will show an error or warning when trying to call it. If no error appears then the problem is in another place.

connecting via editor output and debugger:


connecting via code output and debugger:

I checked it and found no difference. :sob:

Are you instanciating the HurtBoxComponent scene or adding a HurtBoxComponent node(using the add node dialog)? If it’s the second option then that’s normal because connecting the signal in the editor is only saved in the scene (tscn file)

Edit: Yep, I just saw that you are adding the node directly. If you want to connect it in the editor then don’t do that and instantiate the scene instead.

1 Like

Oh, I see. Thank you for your patience to my newbie question.