Witam mam taki kod
kod powinien odczekać 10 sekund wykonać "if" i powtarzać to do końca pętli while, ale program nie odczekuje 10 sekund i nie mam pojęcia dlaczego.
public void move (Vector3 i)
{
z = i;
z.y = transform.position.y;
while (Ko == false)
{
StartCoroutine(times());
if ((i.x == transform.position.x)&&(i.z == transform.position.z))
{
Ko = true;
}
else
{
if(i.x < transform.position.x)
{
z.x = transform.position.x - 0.25f;
} else if (i.x > transform.position.x)
{
z.x = transform.position.x + 0.25f;
}
if (i.z < transform.position.z)
{
z.z = transform.position.z - 0.25f;
}
else if (i.z > transform.position.z)
{
z.z = transform.position.z + 0.25f;
}
gameObject.transform.position = z;
}
}
}
IEnumerator times()
{
yield return new WaitForSeconds(10);
}