Pathfinding npc gets stuck despite path being made

Godot Version

4.7.2

Question

I've got an enemy npc with a navigation agent inside of it that makes it move around the map. For some reason I've yet to find the agent gets stuck around a ramp with walls next to it, despite a path being made.


here’s an image showcasing the problem: the path is made but the guy gets stuck in a wall (which has a ramp behind it)

Here’s the code that calculates the path and the npc’s velocity. The path target is set separately in other functions in the code and works fine.

func _physics_process(delta: float) -> void:
	if not navagent.is_navigation_finished():
		var pos = global_position
		var next_pos = navagent.get_next_path_position()
		var dir = pos.direction_to(next_pos)
		dir.y=0
		
		if dir.length_squared() > 0.0001:
			dir=dir.normalized()
			velocity = dir * speed
		else:
			velocity=Vector3.ZERO
	velocity.y=-2.5
	move_and_slide()

Here’s the navigation agent properties in case they’re at fault. (Also the npc cannot move if Path Desired Distance is 1m for some reason)