The current implementation of GetClosestTask() pathfinds to every available task and calculates their distance to find the closest task. Since only the distances to the tasks are needed and not the path itself I used floodfill instead to improve the efficiency of GetClosestTask(). It expands outwards from the current position until it hits a node that is a valid task and returns this task. This should improve/prevent the stuttering when pathfinding.
The current implementation of
GetClosestTask()
pathfinds to every available task and calculates their distance to find the closest task. Since only the distances to the tasks are needed and not the path itself I used floodfill instead to improve the efficiency ofGetClosestTask()
. It expands outwards from the current position until it hits a node that is a valid task and returns this task. This should improve/prevent the stuttering when pathfinding.