extends CharacterBody2D


const SPEED = 100.0
@onready var player = get_parent().get_node("Player_Melodie")
var player_position = Vector2.ZERO
var target_position = Vector2.ZERO

var move_timer = 2


func _physics_process(delta: float) -> void:
	player_position = player.position
	target_position = (player_position - position).normalized()
	move_and_slide()
	for i in get_slide_collision_count():
		var collision = get_slide_collision(i)

func _process(delta: float) -> void:
	var direction : Vector2 
	if move_timer > 0 :
		move_timer -= delta
		direction = Vector2.ZERO
	else : 
		direction = target_position
	
	$AnimatedSprite2D.play("Generic")
	
	velocity = direction * SPEED
