I'm trying to set up a system where I can have 'teams' of objects that targets the nearest object from another team. I've got some ideas on how this may be done but none of them are very simple .
The problem is basically two-fold
1) Identify nearest target
2) Lock onto the target until some sort of action (like an attack) is complete and then find another target
I'm working on something of a shooter so precision isn't NEARLY as important as simplicity and speed.
Basically, I think you need to run two fastloops - one inside the other.
The first loop selects each "chaser" object, one at a time. The second loop then selects each "target" object, also one at a time, calculates the distance to the selected "chaser", and then compares this to the distance to the previous closest "target".