The do while loop within the following script crashes Unity every time I try to run the scene. If I take the loop out of this script it runs fine, but with it in, Unity just freezes when I hit play. Any idea why?
using UnityEngine;
using System.Collections;
public class FloorDistance : MonoBehaviour {
public GameObject characterPos;
public GameObject floorPos;
Vector3 posChar;
Vector3 posFloor;
public float distance;
void Awake ()
{
posChar = characterPos.transform.position;
posFloor = floorPos.transform.position;
}
void Update()
{
do
{
distance = Vector3.Distance(posChar, posFloor);
} while(distance > 0f);
Debug.Log(distance);
}
}
↧