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):