Quantcast
Channel: Unity Forum
Viewing all articles
Browse latest Browse all 1466670

Pick first object during a sort and then stop sorting

$
0
0
I need something like
//Vector3 nearest = PlayerUnits.Sort(delegate(Transform t) { return (transform.position - t.position).sqrMagnitude; }).First();
to exist...
to where it sorts,, finds the first answer, and then stops sorting how is this possible? the only way to sort that i know of in c# is:

Code (CSharp):
  1.  
  2. private IEnumerator DistanceToTarget()
  3.    {
  4.      //Sort so nearest enemy is always Enemies[0]
  5.      PlayerUnits.Sort(delegate( Transform t1, Transform t2){
  6.        return...
Pick first object during a sort and then stop sorting

Viewing all articles
Browse latest Browse all 1466670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>