public bool FindPath(Vector3 startWorldPoint, Vector3 endWorldPoint, ref List <Vector3> path, bool local)
    {
        PathfindingNode startNode = m_Grid.GetNodeFromWorldPoint(startWorldPoint);

        if (startNode == null)
        {
            return(false);
        }

        PathfindingNode targetNode = m_Grid.GetNodeFromWorldPoint(endWorldPoint);

        if (targetNode == null)
        {
            return(false);
        }

        if (startNode == targetNode)
        {
            return(false);
        }

        // List of nodes for the open list.
        List <PathfindingNode> openList = new List <PathfindingNode>();

        // List of nodes for the closed list.
        HashSet <PathfindingNode> closedList = new HashSet <PathfindingNode>();

        openList.Add(startNode);

        while (openList.Count > 0)
        {
            PathfindingNode currentNode = openList[0];

            for (int i = 1; i < openList.Count; ++i)
            {
                if (openList[i].fCost < currentNode.fCost || openList[i].fCost == currentNode.fCost && openList[i].hCost < currentNode.hCost)
                {
                    currentNode = openList[i];
                }
            }

            openList.Remove(currentNode);
            closedList.Add(currentNode);

            if (currentNode == targetNode)
            {
                path = GetFinalPath(startNode, targetNode, local);
                return(true);
            }

            foreach (PathfindingNode neighborNode in m_Grid.GetNeighboringNodes(currentNode))
            {
                if (neighborNode.isObstacle || closedList.Contains(neighborNode))
                {
                    continue;
                }

                int moveCost = currentNode.gCost + GetManhattenDistance(currentNode, neighborNode);

                if (moveCost < neighborNode.gCost || !openList.Contains(neighborNode))
                {
                    neighborNode.gCost      = moveCost;
                    neighborNode.hCost      = GetManhattenDistance(neighborNode, targetNode);
                    neighborNode.parentNode = currentNode;

                    if (!openList.Contains(neighborNode))
                    {
                        openList.Add(neighborNode);
                    }
                }
            }
        }

        return(false);
    }