fix bugs
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user