I just put together a minimal example to confirm that it's working as expected. The scene and script are pasted below.
nav_test.tscn
[gd_scene load_steps=5 format=3 uid="uid://c7mav27smumdb"]
[ext_resource type="Script" path="res://nav_test.gd" id="1_snbcw"]
[sub_resource type="NavigationPolygon" id="NavigationPolygon_lguo6"]
vertices = PackedVector2Array(725, 192, 581, 246, 485, 243, 449, 159, 497, 112, 599, 58, 767, 46, 944, 153, 817, 232, 993, 333, 839, 310, 761, 363, 856, 465, 663, 513, 587, 369, 473, 516, 344, 348, 305, 501, 198, 457, 204, 109, 248, 106, 320, 201, 101, 306, 107, 159, 151, 122)
polygons = [PackedInt32Array(0, 1, 2, 3, 4, 5, 6), PackedInt32Array(0, 6, 7, 8), PackedInt32Array(8, 7, 9, 10), PackedInt32Array(11, 10, 9, 12, 13), PackedInt32Array(14, 11, 13, 15), PackedInt32Array(16, 14, 15, 17, 18), PackedInt32Array(19, 20, 21, 16, 18, 22, 23, 24)]
outlines = [PackedVector2Array(151, 122, 107, 159, 101, 306, 198, 457, 305, 501, 473, 516, 663, 513, 856, 465, 993, 333, 944, 153, 767, 46, 599, 58, 497, 112, 449, 159, 485, 243, 581, 246, 725, 192, 817, 232, 839, 310, 761, 363, 587, 369, 344, 348, 320, 201, 248, 106, 204, 109)]
[sub_resource type="CircleShape2D" id="CircleShape2D_dxbss"]
radius = 16.0
[sub_resource type="CircleShape2D" id="CircleShape2D_58o3v"]
radius = 16.0
[node name="nav_test" type="Node2D"]
script = ExtResource( "1_snbcw" )
[node name="Position2D" type="Position2D" parent="."]
position = Vector2(533, 186)
[node name="NavigationRegion2D" type="NavigationRegion2D" parent="."]
navpoly = SubResource( "NavigationPolygon_lguo6" )
[node name="npc" type="RigidDynamicBody2D" parent="."]
position = Vector2(240, 152)
gravity_scale = 0.0
can_sleep = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="npc"]
shape = SubResource( "CircleShape2D_dxbss" )
[node name="NavigationAgent2D" type="NavigationAgent2D" parent="npc"]
radius = 16.0
time_horizon = 43.55
[node name="RigidDynamicBody2D" type="RigidDynamicBody2D" parent="."]
position = Vector2(310, 276)
gravity_scale = 0.0
can_sleep = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidDynamicBody2D"]
shape = SubResource( "CircleShape2D_58o3v" )
[node name="NavigationObstacle2D" type="NavigationObstacle2D" parent="RigidDynamicBody2D"]
estimate_radius = false
radius = 16.0
nav_test.gd
extends Node2D
@onready var npc = $npc
@onready var agent = $npc/NavigationAgent2D
@onready var goal = $Position2D
func _ready() -> void:
agent.velocity_computed.connect(on_velocity_computed)
agent.target_reached.connect(on_target_reached)
agent.set_target_location(goal.global_position)
func _physics_process(delta: float) -> void:
var next_location = agent.get_next_location()
var v = (next_location - npc.global_position).normalized()
agent.set_velocity(v * 64.0)
func on_velocity_computed(safe_velocity: Vector2) -> void:
npc.linear_velocity = safe_velocity
func on_target_reached() -> void:
print("reached goal")
get_tree().quit()