From 1fdbecd034a49c61f0ac588ec4252412c0734be8 Mon Sep 17 00:00:00 2001 From: Forrest Date: Tue, 6 Oct 2026 17:59:44 -0400 Subject: [PATCH] Pooled enemy characters stop animating while hidden A released, faded, or cleared character was hidden but its AnimationPlayer kept looping (the #28 soak found 1-55 still animating at the end of a night, and on through the day). EnemyCharacters._hide stops it; acquire already clears the clip, so the next enemy's animation starts at once. Co-Authored-By: Claude Opus 5.5 --- game/scripts/enemy_characters.gd | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/game/scripts/enemy_characters.gd b/game/scripts/enemy_characters.gd index bfaff95..23364df 100644 --- a/game/scripts/enemy_characters.gd +++ b/game/scripts/enemy_characters.gd @@ -168,7 +168,7 @@ func release(id: int, killed: bool) -> void: corpse[c] = CORPSE_TIME _play(c, CLIPS[type[c]]["death"], 0.1) else: - _roots[c].visible = false + _hide(c) func hit(id: int) -> void: @@ -182,7 +182,7 @@ func clear() -> void: for c in type.size(): enemy_id[c] = -1 corpse[c] = 0.0 - _roots[c].visible = false + _hide(c) ## How many characters are drawing an enemy right now (tests). @@ -202,7 +202,7 @@ func _process(delta: float) -> void: if corpse[c] > 0.0: corpse[c] = maxf(corpse[c] - delta, 0.0) if corpse[c] == 0.0: - root.visible = false + _hide(c) continue if enemy_id[c] < 0: continue @@ -246,6 +246,13 @@ func _animate(c: int, d: int) -> void: _play(c, clip, 0.15) +## Back in the pool: hidden, and its animation stopped so an idle character costs nothing (acquire +## clears the clip, so the next enemy's starts on its first frame). +func _hide(c: int) -> void: + _roots[c].visible = false + _anims[c].stop() + + func _play(c: int, clip: StringName, blend: float) -> void: _clip[c] = clip if _anims[c].has_animation(clip):