when reaching the end of navigation2d my node shakes alot and doesnt stop like it should and i dont know why

extends CharacterBody2D

const speed: int = 400

@onready var navigation: NavigationAgent2D = $NavigationAgent2D
@onready var movement_position: Sprite2D = $“…/Movement Position”

func _physics_process(delta: float) → void:
var next_path_position = navigation.get_next_path_position()
var direction = self.global_position.direction_to(next_path_position)
velocity = direction * speed
move_and_slide()

func _input(_event: InputEvent) → void:
if Input.is_action_just_pressed(“Click”):
movement_position.visible = true
navigation.target_position = get_global_mouse_position()
movement_position.global_position = navigation.target_position