[throwing an projectile to the nearest target]

function pass(receiver:Transform){

         var targetDir = receiver.position - transform.position;
         if (hunterBall.rigidbody.GetComponent("BallBehavior").myOwner == transform ){
                 if( Vector3.Angle (transform.forward, targetDir) <130 ){
                 
                     hunterBall.rigidbody.GetComponent("BallBehavior").rigidbody.velocity = targetDir.normalized*passSpeed;
                     hunterBall.rigidbody.GetComponent("BallBehavior").myOwner = null;
                 }
                 else hunterBall.rigidbody.GetComponent("BallBehavior").rigidbody.velocity = transform.TransformDirection(Vector3(0,0,passSpeed));
                 hunterBall.SendMessage ("Thrown");
                 hunterBall.rigidbody.GetComponent("BallBehavior").myOwner = null;
                 
         }
 
 }

So I have this function to pass an projectile from one player to another, the problem here is that I want the projectile to go to the nearest player at an certain distance from it, and not just the one I set on the Transform as a receiver, any thoughts on how I can do that? perhaps set a RayCast and ad force to the projectile directing to whichever player is the closest? would that work? how should I proceed?
Thanks everyone.

Look at the “Another example”:

if you know ahead the other objects, place them all in an array right from the Start and only use the algorithm without FindGameObjectWithTag