Pathfinding/Navigation2D unit stuck problem

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By shooQrow

So basically my units stuck in place, changing their path each tick, i cant find a way how to fix it, was struggling with it for a lot of time, maybe my eyes got blurry and i dont see a simple solution, but i cant find it. Navigation polygons are provided by tilemap and as it seen on screenshots. The movement and pathfinding code are below

func get_unit_path():
    unit_path = Nav.get_simple_path(position, Vector2(16,16), false)
func move_to_target():
    var velocity = position.direction_to(unit_path[1]) * speed
    move_and_slide(velocity)

func _process(delta):
    get_unit_path()

if unit_path.size() > 1:
	move_to_target()