This commit is contained in:
2026-01-11 13:26:12 +01:00
parent 07a7ed3bca
commit 26de2ca6e0
7 changed files with 80 additions and 8 deletions

View File

@@ -181,12 +181,29 @@ func _damaged_behavior(_delta):
state_timer = idle_duration
func _set_animation(anim_name: String):
if current_animation != anim_name:
current_animation = anim_name
current_frame = 0
time_since_last_frame = 0.0
# Validate animation exists before setting it
if anim_name in ANIMATIONS:
if current_animation != anim_name:
current_animation = anim_name
current_frame = 0
time_since_last_frame = 0.0
else:
# Invalid animation name - fall back to IDLE
print("EnemySlime: Invalid animation '", anim_name, "' - falling back to IDLE")
if current_animation != "IDLE":
current_animation = "IDLE"
current_frame = 0
time_since_last_frame = 0.0
func _update_animation(delta):
# Safety check: ensure current_animation exists in ANIMATIONS
if not current_animation in ANIMATIONS:
print("EnemySlime: ERROR - current_animation '", current_animation, "' not in ANIMATIONS! Resetting to IDLE")
current_animation = "IDLE"
current_frame = 0
time_since_last_frame = 0.0
return
# Update animation frame timing
time_since_last_frame += delta
if time_since_last_frame >= ANIMATIONS[current_animation]["frameDurations"][current_frame] / 1000.0: