private List <Cell> Astar() { Astar solver = new Astar(startPos, endPos, grid, Width, Height); List <Cell> path = solver.Process(); if (path == null) { Debug.Log("Was not able to find any viable path! Exit!"); _isSet = false; lineRenderer.enabled = false; } else { string s = ""; foreach (var cell in path) { s += "(" + cell.x + ", " + cell.y + ") "; } Debug.Log("path: " + s); // Raw A* made for object space rawAstarPath = path; rawAStarintermediatePath = ConvertCellsToVector3(path).ToArray(); // Checking if there are corners near an obstacle and moving the corner point by Cellsize / 2 away on x and y path = CheckingCorners(rawAstarPath); // Restart from same position if (_isSet) { path[0].worldPos = transform.position; } // Aplying Bezier float tLength = 0; for (int i = 0; i < path.Count - 1; i++) { tLength += GetEuclidianDistance(path[i].worldPos, path[i + 1].worldPos); } float step = 1 / tLength; List <Vector3> newPath = new List <Vector3>(); for (float t = 0.0f; t <= 1.0f; t += step) { newPath.Add(Bezier.Apply(path, t)); } // LineReader needs an array intermediatePath = newPath.ToArray(); // Make Cells to have both object and world coordinates path = ConvertVector3ToCell(intermediatePath); } return(path); }