private IEnumerator MoveCoroutine(int newX, int newY, float time, bool merge) { gridIndex.X = newX; gridIndex.Y = newY; gridIndex.ChangeName(); Vector3 startPos = transform.localPosition; Vector3 endPos = GridRef.GetWorldPosition(newX, newY); for (float t = 0; t <= 1 * time; t += Time.deltaTime) { transform.localPosition = Vector3.Lerp(startPos, endPos, t / time); yield return(0); } transform.localPosition = endPos; if (merge) { Destroy(transform.gameObject); } }