Signal already connected to callable when the names are the same

Godot Version

Godot 4.2

Question

I have a LifeComponent node with a script that handles damage.
class_name LifeComponent

extends Node
signal die
@export var max_life: int
@export var life: float

func damage(damage):
	life -= damage
	if life <= 0:
		die.emit()

I also have a player and BaseEnemy class with death functions:
#In player.gd
#Connected to a child PlayerLifeComponent that extends LifeComponent

func die() -> void:
	visible = false
	await get_tree().create_timer(1).timeout
	visible = true

#PlayerLifeComponent

extends LifeComponent
func damage(damage):
	life -= damage
	if life <= 0:
		die.emit()
	else:
		update_life_check()
#Has other code unrelated to the issue

#In base_enemy.gd
#Connected to a child LifeComponent ‘die’ signal

func die() -> void:
	queue_free()

When I change the function name in BaseEnemy to anything other than die() then no error occurs. However, the player script also has a function die() that doesn’t cause an error even though it also has the same name as the signal emitted. What is the difference between the two? I tried changing the name of the player’s death function to something different, but it had no affect on the error. Only changing the name of the function in base_enemy.gd got rid of the error message.Preformatted text

Related to other solved issue.

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