private void RefinePath(List <Node> path) { List <Node> smoothPath = new List <Node> (); int nodeDiameter = grid.GetNodeDiameter(); for (int i = 0; i < path.Count; i++) { Debug.Log(i); Vector3 currentPoint = path[i].GetWorldPos(); for (int o = i + 1; o < path.Count; o++) { Vector3 endPoint = path[o].GetWorldPos(); bool there = false; ///* while (!there) { currentPoint = Vector3.MoveTowards(currentPoint, endPoint, 0.1f); Node CurrentNode = grid.NodeFormWolrdPoint(currentPoint); if (CurrentNode == path[i]) { continue; } else if (CurrentNode == path[o]) { there = true; } else if (CurrentNode.GetWalkable() == false) { smoothPath.Add(path[o - 1]); i = o - 1; Debug.Log(o); break; } } //*/ if (!there) { break; } } } smoothPath.Add(path [path.Count - 1]); ///* foreach (Node n in smoothPath) { Debug.Log(n.GetWorldPos()); } //*/ //Debug.Log (smoothPath); //grid.SetPath(path, startNode, targetNode); }