I have a list of about 8 items of which they possess a one of the possible 2 values. So it could go like this… 2,8,8,8,2,2,8,2… and Im trying to get the lower values… Ill show the code it feels like there so much more code then there really needs to be.
void FindLowerVertices()
{
float higher = 0;
float lower = 0;
float unknown;
bool lowerFound = false;
while (lowerFound == false)
{
foreach (Vector3 vertice in transformedVertices)
{
unknown = vertice.y;
foreach (Vector3 verticeCheck in transformedVertices)
{
if (verticeCheck.y < unknown)
{
higher = unknown;
lower = verticeCheck.y;
lowerFound = true;
}
if (verticeCheck.y > unknown)
{
lower = unknown;
higher = verticeCheck.y;
lowerFound = true;
}
}
}
}
foreach (Vector3 vertice in transformedVertices)
{
if (vertice.y == lower)
{
if (!(siftedFloorVertices.Contains(vertice)))
{
siftedFloorVertices.Add(vertice);
}
}
}
}
I was looking up the linq function min group by and i thought it would be able to help me but I was finding it hard to implement it. Can someone help?