FreeFlow Combat System: Targeting enemies?

you can use Dot product to compare the orientation of normalized vectors. a dot product between 2 vectors will give you a score between -1 and 1 representing the similarity between the vector’s orientation.

so subtract your pawn’s location from a potential target’s location, to get a vector pointing from pawn to target. then normalize this vector. then dot product this with the forward vector of your pawn’s rotation.

do this for all targets, and the target with the highest dot product will be the one closest to the front of your pawn, but you may want to factor distance into the calculation, so closer things have higher priority. you can do that by multiplying the distance of a target by a small fraction, then subtracting it from the dot product score.