public var speed : float;
//var check : float;
function Start () {
}
function Update()
{
while(transform.position.x != 15f)
{
transform.position.x += speed * Time.deltaTime;
yield WaitForSeconds(0);
}
transform.position.x -= speed * Time.deltaTime;
}
Kiwasi
October 20, 2014, 9:30am
3
Once the code is formatted properly it becomes obvious
You are trying to make Update a coroutine
You are comparing floats directly
Because the code is not properly formatted.
The actual reason is that you are comparing float values using == operator which is very very very less likely scenario. Hence your loop is going into infinity.
Use Mathf.Approximately to compare like:
while(!Mathf.Approximately(transform.position.x, 15f))