I am trying to make a sprite stop moving when it's x and y are the same as the mouse's.
For some reason, once the image is in the same position as the mouse the image starts going back and forth in the same axis really fast. I need to make it stop moving.
func _physics_process(delta):
var move_vec = Vector2()
var look_vec = get_global_mouse_position() - global_position
//this gets the mouse and sprite position
if move_vec != look_vec: // if mouse and sprite are not the same then move.
move_vec = look_vec
move_vec = move_vec.normalized()
move_and_collide(move_vec * speed * delta)
global_rotation = atan2(look_vec.y, look_vec.x)
else:
pass`enter code here`