Implemented pathfinding.