From c3375d6305223662a21a0864fc497699cd9fcd05 Mon Sep 17 00:00:00 2001 From: Artur <2123806@stud.th-mannheim.de> Date: Wed, 3 Jun 2026 17:23:28 +0200 Subject: [PATCH] fixed tornado no-damage bug --- scripts/tornado.gd | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/tornado.gd b/scripts/tornado.gd index 7926e0f..7013bd6 100644 --- a/scripts/tornado.gd +++ b/scripts/tornado.gd @@ -9,7 +9,6 @@ extends Area2D @onready var explosion_collision: CollisionShape2D = $ExplosionCollision var _is_pulling := true -var _damaged_enemies: Array[Node] = [] func _ready() -> void: tornado_area.disabled = false @@ -31,15 +30,14 @@ func _physics_process(delta: float) -> void: func _explode() -> void: _is_pulling = false + var targets = get_overlapping_bodies().filter(func(b): return b.is_in_group("enemies") and not b.is_dying) tornado_area.disabled = true explosion_collision.disabled = false if animated_sprite_2d.sprite_frames.has_animation("explosion"): animated_sprite_2d.play("explosion") - await get_tree().physics_frame - for body in get_overlapping_bodies(): - if body.is_in_group("enemies") and not _damaged_enemies.has(body): + for body in targets: + if is_instance_valid(body): body.take_damage(explosion_damage) - _damaged_enemies.append(body) if animated_sprite_2d.sprite_frames.has_animation("explosion"): await animated_sprite_2d.animation_finished else: