Using Unity 2019.3.6f (with pro version 4.2.14), i’ve come across a weird situation where ABPath.Construct
returns the warning below, but only if the GameObject with the Pathfinder component, isn’t first selected in the inspector:
Path Failed : Computation Time 0.00 ms Searched Nodes 0
Error: Couldn’t find a node close to the end point
Process that prompts the warning above:
- Enter Play Mode
- Call
ABPath.Construct
- Warning prompted
Process that works as expected:
- Enter Play Mode
- Click on the GameObject which has the Pathfinder component attached to it in the inspector
- Call
ABPath.Construct
- Path is calculated correctly and without warning
I’m creating the graphs at runtime with the following:
private GridGraph CreateGraph(int width, int depth, int cellSize = 1)
{
GridGraph gridGraph = m_astar.data.AddGraph(typeof(GridGraph)) as GridGraph;
gridGraph.rotation.x = -90;
gridGraph.SetDimensions(width, depth, cellSize);
gridGraph.collision.heightCheck = false;
gridGraph.collision.collisionCheck = false;
gridGraph.Scan();
m_astar.FlushWorkItems();
return gridGraph;
}
Query that prompts the warning:
ABPath path = ABPath.Construct(start, target, (p) =>
{
// path calculated
});
Other notes:
The warning is only prompted if the GameObject with the Pathfinder component hasn’t been clicked on that session; once it has been clicked, it can be unselected in the inspector and everything continues to function as expected.
Any help or advise as to what might be going on would be great, thanks!