Cannot Load Next Level After Being Able To Match The Position In Vector 2

#pragma strict

// This Script is called when the User Clicks on the Frog.



var FrogName : GameObject;
var frogone : GameObject;
var frogtwo : GameObject;
var frogthree : GameObject;
var frogfour : GameObject;
function Start(){


FrogName = GameObject.Find(this.name); 

}

function OnMouseDown(){
var Target = GameObject.Find("Script").GetComponent(FourFrogChangePosition);
var Target2 = GameObject.Find("Script").GetComponent(FourFrogProperty);
frogone = GameObject.Find("frog1");
frogtwo = GameObject.Find("frog2");
frogthree = GameObject.Find("frog3");
frogfour = GameObject.Find("frog4");

if (Target.Firstclick ==null){
Target.Firstclick =FrogName;
return;
}

if (Target.Firstclick !=null && Target.Secondclick ==null){
Target.Secondclick =FrogName;
Target2.Start();
Target.changePosition();
	if(frogone.transform.position == Vector2(-1.343934f, 1.600096f) && frogtwo.transform.position == Vector2(2.960639f, -0.5253699f) && frogthree.transform.position == Vector2(1.920852f, 1.716066f) && frogfour.transform.position == Vector2(-1.871236f, -0.6542034f) ){
		yield WaitForSeconds (2.5);
		Application.LoadLevel("Pond Level Medium");
}

	if(frogone.transform.position == Vector2(-1.871236f, -0.6542034f) && frogtwo.transform.position == Vector2(2.960639f, -0.5253699f) && frogthree.transform.position == Vector2(1.920852f, 1.716066f) && frogfour.transform.position == Vector2(-1.871236f, -0.6542034f) ){
		yield WaitForSeconds (2.5);
		Application.LoadLevel("Pond Level Medium");
}	
return;
}
}

the code above does not load to my next scene.

Oh my, those comparisons are just awful.

  • Never compare float to some specific number, as floats tend to “float”. Use Mathf.Approximately() instead, Unity - Scripting API: Mathf.Approximately
  • It would be nicer to actually have transform points in 3d space rather than manually writing those values.