public void Run() { if (m_Graph == null) { Debug.LogError("The assigned graph is either not assigned or invalid."); return; } // Clear state of previous run m_Path.Clear(); m_Graph.Clear(); // Convert start and end locations to nodes in the graph var start = m_Graph.GetClosestNodeToPoint(m_Start); var goal = m_Graph.GetClosestNodeToPoint(m_End); if (start == goal) { Debug.LogError("Start and goal are the same node. No path was found."); return; } // Create a dictionairy to keep track of how we // discovered a node. var cameFrom = new Dictionary <Node, Node>(); // Execute the algorithm we have selected. AStarSearch.Execute(m_Graph, start, goal, cameFrom); // Initialize the Hermite curve with the path just found hermiteCurve = GetComponent <DebugCurve>(); hermiteCurve.controlPoints = m_Path; hermiteCurve.Init(); // Reconstruct Path ReconstructPath(cameFrom, start, goal, m_Path); }