Navmesh path not being followed?

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

I have fixed a previous issue of mine, but there is slight jittering (not current problem) and the whole reason I implemented the navmesh is not functioning, since the enemy still just walks towards me apparently.

Here is the code for the enemy, I can provide screenshots, but I don’t know how to upload my project.

other problems include the fact that i cannot use the ysort with the navmesh, they just dont work together?

Extends KinematicBody2D

const MOVE_SPEED = 190
const DETECT_RANGE = 200
const ATTACK_DIST = 100

onready var sprite = $Sprite
onready var anim = $AnimationPlayer
onready var nav = get_parent()
onready var raycast = $RayCast2D
onready var timer = $Timer


var path = []
var path_ind = 0
var player = null

func _ready():
	add_to_group("ninja")


func move_to(target_pos):
	path = nav.get_simple_path(global_position, target_pos)
	path_ind = 0
	
func _physics_process(delta):
	if player == null:
		return
	if player.global_position - global_position > Vector2(DETECT_RANGE, DETECT_RANGE):
		return
	if path_ind < path.size() :
		var move_vec = path[path_ind] - global_position
		if move_vec.length() < 1:
			path_ind += 1
		else:
			move_and_slide(move_vec.normalized() * MOVE_SPEED)
	
	var target = raycast.look_at(player.global_position)



func set_player(p):
	player = p


func _on_Timer_timeout():
	if player.global_position - global_position <= Vector2(DETECT_RANGE, DETECT_RANGE):
		move_to(player.global_position)

https://i.imgur.com/NwQxoBp.png

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here