Question
i am trying to make a simple AI that follows the player but cant make it do what it wants the enemy just moves away from the player
extends CharacterBody2D
const SPEED = 5
@onready var player_node := get_node("../Player")
func _physics_process(_delta: float) -> void:
var player_POS = player_node.global_position
var distance = position.distance_to(player_POS)
look_at(player_POS)
if distance > 20:
velocity = position
else:
velocity = Vector2.ZERO
move_and_slide()