Improving A* path finding efficiency in a 2D Grid based Unity game
public List<Node> FindPath(Vector2Int start, Vector2Int target) { List<Node> openSet = new List<Node>(); HashSet<Node> closedSet = new HashSet<Node>(); Node startNode = grid.GetNode(start); Node targetNode = grid.GetNode(target); openSet.Add(startNode); while (openSet.Count > 0) { Node currentNode = openSet[0]; for (int i = 1; i < openSet.Count; i++) { if (openSet[i].FCost < currentNode.FCost || (openSet[i].FCost == currentNode.FCost && openSet[i].HCost […]