extends Node2D var speed = 10 var health = 30 var total_health = 30 var dead = false @export var player : CharacterBody2D @onready var navigation : NavigationAgent2D = $NavigationAgent2D @onready var health_bar : ProgressBar = $HealthBar func _physics_process(delta: float) -> void: health_bar.value = (float(health)/total_health)*100 navigation.target_position = player.position position = position.move_toward(navigation.get_next_path_position(), delta*speed) if dead: queue_free() func damage(damage : int): health -= damage if health <= 0: dead = true return -health return 0