public static void SmoothPath(FastList <GridNode> nodePath, Vector2d End, FastList <Vector2d> outputVectorPath, int unitSize) { outputVectorPath.FastClear(); length = nodePath.Count - 1; //culling out unneded nodes var StartNode = nodePath[0]; outputVectorPath.Add(StartNode.WorldPos); GridNode oldNode = StartNode; long oldX = 0; long oldY = 0; long newX = 0; long newY = 0; for (i = 1; i < length; i++) { GridNode node = nodePath[i]; bool important = false; if (unitSize <= 1) { important = !node.Clearance; } else if (unitSize <= 3) { important = !node.ExtraClearance; } else { important = true; } //important = true; if (important) { newX = node.gridX - oldNode.gridX; newY = node.gridY - oldNode.gridY; if ( (newX <= 1 && newX >= -1) && (newY <= 1 && newY >= -1) ) { if (newX == oldX && newY == oldY) { if (oldX != 0 || oldY != 0) { outputVectorPath.RemoveAt(outputVectorPath.Count - 1); } } else { oldX = newX; oldY = newY; } } else { oldX = 0; oldY = 0; } outputVectorPath.Add(node.WorldPos); oldNode = node; } } outputVectorPath.Add(End); }