extends CharacterBody2D @export var speed = 50.0 @export var max_health = 40 var _health = max_health func _process(delta): get_parent().set_progress(get_parent().get_progress() + speed * delta) if get_parent().get_progress_ratio() == 1: queue_free() func deal_damage(damage): _health -= damage if _health <= 0: queue_free() else: _update_color() func _update_color(): var ratio : float = float(_health) / max_health var target_color = Color(1, ratio, ratio) $Sprite2D.modulate = target_color