Y
Y
yraiv2022-03-04 19:09:47
Unity
yraiv, 2022-03-04 19:09:47

How to compare elements from a list with each other?

I'm making a 2D game in Unity. It is necessary to compare all elements from the List with each other and select those that have the largest number.
For example, there are: 2, 4, 5, 1, 5, 2, 5. and at the end there should be 3 elements with fives, because they are the largest numbers.

List<GameObject> zombieArray = new List<GameObject>();

for (int i = 0; i < zombieArray.Count; i++)
        {
            zombieArray[i].GetComponent<ZombieStandart>().NewPosition  '=  //  NewPosition - переменная (int), которую я хочу сравнивать у всех этих элементов и отбирать все те элементы, у которых вышло наибольшее число 
        }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question