IEnumerator move(List <Node> path, Map theMap, bool isPlayer) { movingLong = true; moveBlocked = false; //index of next tile to move toward in path sequence int pathIndex = 0; // lastPosition is the final target node in path sequence Node finalPosition; finalPosition = path[path.Count - 1]; while (((currX != finalPosition.getXPos()) || (currY != finalPosition.getYPos())) && !moveBlocked) { if (!movingOne) { //confirm no other unit is blocking the move Tile nextTile = theMap.getTile(path[pathIndex].getXPos(), path[pathIndex].getYPos()); moveBlocked = collisionManager.CheckForBlocked(nextTile, theMap); if (!moveBlocked) { moveOneRoutine = StartCoroutine(MoveOneTile(transform.position, new Vector2(path[pathIndex].getXPos(), path[pathIndex].getYPos()), 1f, theMap, isPlayer)); pathIndex++; } } yield return(null); } //move complete, reset position, flags and stop animation transform.position = new Vector2((float)Math.Round(transform.position.x), (float)Math.Round(transform.position.y)); movingLong = false; }