private IEnumerator MoveToVertexIE(Vertex newVertex) { isMoving = true; Vector2 newPos = newVertex.transform.position; Vector2 offset = newPos - (Vector2)transform.position; transform.eulerAngles = new Vector3(0f, 0f, Utilities.VecToAngle(offset)); float dist = -1; float prevDist; while ((Vector2)transform.position != newPos) { float boost = Boost.BOOST() ? 2f : 1; Vector2 movement = (Vector3)offset * speed * boost * upgradespeed * Time.deltaTime; transform.position += (Vector3)offset * speed * boost * upgradespeed * Time.deltaTime; prevDist = dist; dist = Vector2.Distance(transform.position, newPos); if ((dist > prevDist || Vector2.Distance((Vector2)transform.position + movement, newPos) > dist) && prevDist != -1) { transform.position = newPos; } yield return(null); } transform.position = newPos; currentVertex = newVertex; isMoving = false; if (isFirst) { pickUp.PickUpDrop(); } }