Enemy priority attack system (Sort every player health hp)

I want to make an enemy attack system, which revolves around 3 things:
Player health, How many players are grouped up, Players with no evasion skills

But I would like to focus more on the first topic, player health. I want the boss to prioritize players with the lowest hp. I did some research but I didn’t find anything that could help me organize it in a way so that the enemy is free to do whatever he wants. I’ll give you some context:

Enemy has 3 abilities, one that works in <10m range, other with <40, and another at <80m.
So:
[Attack player 1 = 20 hp] - If player 1 has distance.magnitude > 80, attack player 2
[Attack player 2 = 35 hp] - If no players are in range, dash towards closest player until
distance.magnitude < 65

This is a print of the code that I was trying to do, I want to put the code mentioned above inside the red box.

I was able to do it, I will keep the answer here so people in the future will be able to see it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.