Skip to content

A complete AI agency at your fingertips - From frontend wizards to Reddit community ninjas, from whimsy injectors to reality checkers. Each agent is a specialized expert with personality, processes, and proven deliverables.

Shell

fix(godot): emit died only once per death

Rudy Celeklicb9160eb448f
diff --git a/game-development/godot/godot-gameplay-scripter.md b/game-development/godot/godot-gameplay-scripter.md
index 42e8d2e9..c747562b 100644
--- a/game-development/godot/godot-gameplay-scripter.md
+++ b/game-development/godot/godot-gameplay-scripter.md
@@ -89,6 +89,8 @@ func _ready() -> void:
_current_health = max_health
func apply_damage(amount: float) -> void:
+ if _current_health == 0.0:
+ return # already dead; `died` must not fire again
_current_health = clampf(_current_health - amount, 0.0, max_health)
health_changed.emit(_current_health)
if _current_health == 0.0:
@@ -137,6 +139,8 @@ public partial class HealthComponent : Node
public void ApplyDamage(float amount)
{
+ if (_currentHealth == 0f)
+ return; // already dead; Died must not fire again
_currentHealth = Mathf.Clamp(_currentHealth - amount, 0f, MaxHealth);
EmitSignal(SignalName.HealthChanged, _currentHealth);
if (_currentHealth == 0f)