For loop has 'if-else' impossibility.

An if else statements inside my for loop is giving impossible print readouts.

void CheckDistance()
	{
		//Gets a list of all the heroes, nulls the ones that are too far away
		//Or are the players hero.
		//And it's really not working.
		Hero = GameObject.FindGameObjectsWithTag("Player");
		bool OneInRange = false;
		if(Hero.Length > 1)
		{
			//Now we have to enabled each icon.
			//And have it follow the appropriate guy...
			
			for(int x = 0; x < Hero.Length; x++)
			{
				print("HERO CHECK:" + Hero.Length + x + (HeScript.MyHero).name + Hero[x].name);
				if(Vector3.Distance(Hero[x].transform.position,transform.position) > 4 && gameObject != HeScript.MyHero)
				{
					print("HERO FAR");
				}
				else
				{
					print("HERO Close");
					//Hero[x] = null;
				}
					
			}
		}
	}

But here’s what it prints out:

HERO CHECK/
HERO FAR/
HERO CHECK/
HERO CHECK

Which should be impossible since either the if statement is true and it prints HERO FAR or it isn’t and it prints HERO CLOSE.

But it somehow prints HERO CHECK and just skips it twice… I even commented out the nulling line and it still did the same thing.

I’m totally baffled, any ideas?

EDIT:

Just added a print statement (Print(“END FOR”)) to the end of the for loop.
Now it reads

HERO CHECK/
HERO FAR/END FOR/
HERO CHECK/
HERO CHECK

So basically it looks like it doing a full loop then… Something that I have no idea about.

You have Collapse turned on in the Console I’d bet.

[10665-screen+shot+2013-05-03+at+07.33.27.png|10665]

If it should be printing either FAR or CLOSE but prints neither, then it’s not getting that far. My guess is it’s tossing an exception just before that, line 15, something in there not set right. Set a breakpoint there and examine all the values. My guess is there’s an undefined or null in there.