So I have an AI service that finds all enemies within a maximum distance from the AI. It makes sure each possible target has more than 0 health and that it can be seen. I have three arrays, PossibleTargets(character array), TargetDistances (float array), and TargetHealth (float array). Which I have populated with each target, their distance to the AI, and their current health.
The question is: How do I find a target with the best of both worlds; the enemy that is the closest to the controlled AI and has the least health? (while still prioritizing the target that is closest)