- Home /
Get highest Vector3 from list (using Linq?)
Suppose I have this.
 List<Vector3> myVectors;
 float maxY; // how do I get this value from the list of vectors?
What I want is to, possibly using Linq, find the individual float value that is the highest Y value from the myVectors list.
I have no clue as to how to do this. Anybody know?
Thank you kindly.
               Comment
              
 
               
              Checkout the List.Sort method. It's generally quite a bit faster than Linq, with the added benefit of operating on the existing List instance (meaning anything referencing it sees the new sort order as well).
Answer by jenci1990 · Jan 22, 2015 at 06:46 AM
You can do this:
         float maxY = myVectors[0].y;
         for (int i = 0; i < myVectors.Count; i++) {
             if (myVectors[i].y > maxY) maxY = myVectors[i].y;
         }
         //Now you can use maxY value
         Debug.Log(maxY);
Your answer
 
 
             Follow this Question
Related Questions
Drawing a Mandelbrot Set problem 0 Answers
A node in a childnode? 1 Answer
Sort List by string field 1 Answer
Distribute terrain in zones 3 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                