Godot Version
4.6.2
Question
Ok so I am making a boss that follows the player and it seemed to work just fine, but now it is saying that it is a breakpoint. I think the issue is in getting thee player position but I’m not sure.
here is the code (also the break point is the direction = player.position - position):
@onready var player = get_parent().find_child("Player")
@onready var animated_sprite = $AnimatedSprite2D
var direction : Vector2
func _ready():
set_physics_process(false)
func _process(_float) -> void:
direction = player.position - position
if direction.x < 0:
animated_sprite.flip_h = true
else:
animated_sprite.flip_h = false
func _physics_process(delta):
velocity = direction.normalized() * 40
move_and_collide(velocity * delta)
func damaged():
animated_sprite.play("damaged")