index number problems Forloop

i cant seem to get the right index number.
it does set the lowest number but it always returns i = 0 in the debug log.

it must be somthing simple but i cant see it.

public void  FindClosest(){
		if (CurrentTargets.Count == NodeDistances.Count) {
			int Lowest = 99999;
			int indexNumber = 0;
			for (int i = 0; i < NodeDistances.Count - 1; i++) {
				if (Lowest > NodeDistances *) {*

_ Lowest = NodeDistances ;_
* indexNumber = i;*
* Debug.Log (i + “lowest Number” + Lowest );*
* }*
* }*
* target = CurrentTargets [indexNumber];*

* PathRequestManager.RequestPath (transform.position, target.position, OnPathFound);*
* }*
* }*

Your loop indexer is wrong and will cause the last array element to not be processed. This:

i < NodeDistances.Count - 1

Should be:

i < NodeDistances.Count 

That said, I don’t see how that could cause the problem you describe (based on the mentioned sample data). Nothing else jumps out at me, but it should be easy to find by adding some additional Debug.Log statements. Dump everything you’re working with in the loop (current index, current value, Lowest" value, etc) and see what’s not right.