[AI] Scoring Waypoints Based on Closest Distance

I have a Method that scores each waypoint on the map to get the most appropriate waypoint based on a few factors.

  • If Last Waypoint, Skip it
  • If AI is able to see the waypoint(even if he turns) add 2 to score(uses Line-casting)
  • Add the Dot(normalized eg. +1 to -1) product of where the ai is facing and the direction to the waypoint

Using those factors i almost get what i want but in some cases(image below) it takes the furthest and moves against/through a wall:

Problem Example Image

The Green path is where i want it to go, but it goes the the red path.

Question: Is their a way i can give points based on distance(preferably without condition statements), so that the closer a waypoint is the more points it gets?

Sure. Simply measure the distance to each way point with Vector3.Distance. Multiply the result by some scale factor, and add to your score.