Navigation Agent 2D safe velocity doesn't update

Godot Version



For some reason the safe velocity will be equal to the intended velocity of an object on the first frame, and then just never update after that. I know the velocity computed signal is being sent more than once, and I am calculating the next path position (there was one reddit post where that was the issue, I haven’t been able to find much else). Is there some way to force the agent to update safe velocity?

Relevant parts of the script (it’s a complete mess, I’m not that great at programming):

func _physics_process(delta):
	if Target != null:
		$WallDetector.target_position = Target.global_position - global_position
		Distance = calculate_distance()
		Dir = Vector2(Target.global_position.x - global_position.x, Target.global_position.y - global_position.y).normalized()
	var Direction : Vector2 = Vector2.ZERO
	Direction = to_local(Navigation_Agent.get_next_path_position()).normalized()
	if (Distance > Min_Distance or $WallDetector.is_colliding()) and $Health.Is_Alive:#Yes I know this is a horrible if statement. No I am not going to fix it.
		var Intended_Velocity : Vector2 = Direction * Speed
		Use_Nav_Agent = true
		velocity = Intended_Velocity #This is just here so the objects don't crash into a wall, I have a raycast displaying the safe_velocity
        pass # there are some other navigation things that aren't important

func _on_navigation_agent_2d_velocity_computed(safe_velocity):
	$safe_dir.target_position = (safe_velocity + global_position).normalized() * 50#Debugging
	Navigation_Agent.get_next_path_position() #Tried putting this in the signal, it didn't work