Colorizing the path

Here solution for colorizing the final path.

    private void HaltSearchIfEndFound()
    {
        if (searchCenter == endWaypoint)
        {
            Debug.Log("Search stopped cause Search Center is end");
            isRunning = false;
            ColorTheTrail(); // colorizing the path after stop
        }
    }

    private void ColorTheTrail()
    {
        Waypoint paintedWaypoint = searchCenter.exploredFrom;
        while (paintedWaypoint != startWaypoint)
        {
            paintedWaypoint.SetColor(Color.grey);
            paintedWaypoint = paintedWaypoint.exploredFrom;
        }
    }
2 Likes

Thank you!

Privacy & Terms