So I’ve narrowed it down to the while loop by commenting it out and testing it. So I have no idea why but some times it works in play mode every time, then I exit play mode, re enter play mode and it freezes up and I have to manually end the application.
if (BlueSquareClicked == true && Physics.Raycast (camRay, out hit, camRayLength, BlueMoveMask))
{
Debug.Log ("Clicked on BlueMoveTile");
startPoint = transform.position;
endPoint = hit.transform.position;
BlueSquareMoving = true;
float journeyLength = Vector3.Distance (startPoint, endPoint);
float distCovered = (Time.time - startTime) * moveSpeed;
float journey = distCovered / journeyLength;
while (BlueSquareMoving == true)
{
Debug.Log ("Here");
//BlueSquareMoving = false;
transform.position = Vector3.Lerp (startPoint, endPoint, journey);
//Debug.Log ("Moving");
if (transform.position == endPoint)
{
Debug.Log ("Finished Moving");
BlueSquareMoving = false;
BlueSquareDoneMoving = true;
BlueSquareClicked = false;
GameManager.killTiles = true;
}
}
}
Any Help would be awesome. If I need to post the entire script let me know.