Title explains most of it. I'm trying to move the enemy to the player. For some reason, the enemy seems to start moving towards the player (floating) and then when the player starts moving, the enemy starts going up and away from the player? I have no idea what could be going wrong, as everything I've searched through so far seems to be roughly the same and should therefore work?
Code:
func _physics_process(delta):
if areaExported2:
var velocity = (areaExported2.global_position - global_position).normalized()
move_and_collide(velocity * SPEED * delta)
func _on_EnemyDetectionRange_area_entered(area):
if not area.is_in_group("player"):
pass
if area.is_in_group("player"):
areaExported2 = area
func _on_EnemyDetectionRange_area_exited(area):
if not area.is_in_group("player"):
pass
if area.is_in_group("player"):
areaExported2 = null
Thank you for any responses, I'm completely stumped as to what it could be.