public void SetPath(GameObject destination) { if (canMove) { if (destination == lastTile) { canMove = false; for (int i = 0; i < currentPath.Count; ++i) { character.AddDestination(currentPath[i].transform.position); } character.state = CharacterMovement.charState.move; } else if (isValidTile(destination)) { List <GameObject> pathToDestination = Astar(lastTile, destination); if (pathToDestination.Count > 0) { lastTile = destination; for (int i = 0; i < pathToDestination.Count; ++i) { path.Push(pathToDestination[i]); --speed; } for (int i = 0; i < pathToDestination.Count; ++i) { //path.count would always stop after 2 pops? currentPath.Add(path.Pop()); } GetMovementTiles(destination, speed); } } } }