Can anyone explain why I’m going wrong… I don’t understand :S
float Move_Speed = 0.053f;
IEnumerator MoveToWaypoint()
{
float dist = Vector2.Distance(currentWaypoint.transform.position, transform.position);
float time = dist / Move_Speed;
for(float f = 0; f < time; f += Time.deltaTime)
{
Debug.Log(f + " " + time);
transform.Translate(((currentWaypoint.transform.position - transform.position).normalized) * Move_Speed);
yield return new WaitForFixedUpdate();
}
}
It takes about 2 seconds to reach the target… but it calculates it as 27 seconds and wont stop moving back and forth over the target until 27 seconds is up. Can anyone advise?