Path == 0?

Can someone explain the if(path.count == 0) then run the code part?
i printed to see how many path counts i had an it was 14 but when does it ever go to 0 for the code to be calculated?

That should only be the case in the very beginning before it has calculated a path yet. It is done that way so that it only calculates the path one time, and not over and over again.

i understand that part i think. What i dont understand is when does the amount of paths or what ever turn 0

Hi Jayy,

I assume you are referring to the following method in the Pathfinder class, aren’t you?

public List<Waypoint> GetPath()
{
    if (path.Count == 0)
    {
        CalculatePath();
    }

    return path;
}

The method is public. It can be called by everything referencing the current Pathfinder object but we cannot ensure that CalculatePath() has been already called when that happens. To prevent errors, we check the number of elements in our List.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms