extends Area2D const SPEED = 200 @onready var animated = $AnimatedSprite2D var target : Node2D = null var trans : bool var direction @onready var timer = $Timer # Called when the node enters the scene tree for the first time. func _ready() -> void: animated.play("ROLL") timer.start() direction = 1 # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: global_position.x += direction * SPEED * delta if target: if target.has_method("take_damage"): target.take_damage(1) func _on_body_entered(body: Node2D) -> void: if body.is_in_group("Player"): target = body func _on_body_exited(body: Node2D) -> void: if body.is_in_group("Player"): target = null func _on_timer_timeout() -> void: direction *= -1 timer.start()