Hi,
I am still not understanding what goes wrong but if I create GO for all dots and call scan, path is working but path is not able to find any target once nodes are created like this :
AstarPath.active.AddWorkItem(new AstarWorkItem(ctx => {
for (int i = 0; i < dots.Count - 1; i++)
{
Int3 pos1 = (Int3)dots[i];
Int3 pos2 = (Int3)dots[i + 1];
pg.AddNode(pos1);
pg.AddNode(pos2);
PointNode pn1 = pg.nodes[pg.CountNodes() - 2];
PointNode pn2 = pg.nodes[pg.CountNodes() - 1];
pn1.Tag = 3;
pn2.Tag = 3;
var cost = (uint)(pn1.position - pn2.position).costMagnitude;
//pn1.AddConnection(pn2, 0);
//pn2.AddConnection(pn1, 0);
GraphNode.Connect(pn1, pn2, cost);
}
pg.RebuildNodeLookup();
}));
I can see the green lines between all nodes so it should be correct. I am not able to debug inside the package, but the searchnode count remains 0 but pointgraph.nodes contains the nodes above!
I tried to enable optimizeforsparse but I am getting this error :
NullReferenceException: Object reference not set to an instance of an object.
Pathfinding.PointGraph.GetNearest (UnityEngine.Vector3 position, Pathfinding.NNConstraint constraint, System.Single maxDistanceSqr) (at ./Library/PackageCache/com.arongranberg.astar@5.1.4/Graphs/PointGraph.cs:204)
AstarPath.GetNearest (UnityEngine.Vector3 position, Pathfinding.NNConstraint constraint) (at ./Library/PackageCache/com.arongranberg.astar@5.1.4/Core/AstarPath.cs:2190)
Pathfinding.OffMeshLinks.ClampSegment (Pathfinding.OffMeshLinks+Anchor anchor, Pathfinding.GraphMask graphMask, System.Single maxSnappingDistance, Pathfinding.OffMeshLinks+Anchor& result, System.Collections.Generic.List`1[T] nodes) (at ./Library/PackageCache/com.arongranberg.astar@5.1.4/Core/Misc/OffMeshLinks.cs:417)
Pathfinding.OffMeshLinks.Refresh () (at ./Library/PackageCache/com.arongranberg.astar@5.1.4/Core/Misc/OffMeshLinks.cs:579)
Pathfinding.WorkItemProcessor.ProcessWorkItems (System.Boolean force, System.Boolean sendEvents) (at ./Library/PackageCache/com.arongranberg.astar@5.1.4/Core/Misc/WorkItemProcessor.cs:360)
Pathfinding.WorkItemProcessor.ProcessWorkItemsForUpdate (System.Boolean force) (at ./Library/PackageCache/com.arongranberg.astar@5.1.4/Core/Misc/WorkItemProcessor.cs:416)
AstarPath.PerformBlockingActions (System.Boolean force) (at ./Library/PackageCache/com.arongranberg.astar@5.1.4/Core/AstarPath.cs:895)
AstarPath.Update () (at ./Library/PackageCache/com.arongranberg.astar@5.1.4/Core/AstarPath.cs:878)
Without sparse option, manually calling GetNearest for the start & end points give valid nodes. I am calling the search like this :
NNInfo inf = pg.GetNearest(destPathPos, NNConstraint.None);
GraphNode nodeDest = inf.node;
destPathPos = (Vector3)nodeDest.position;
inf = pg.GetNearest(sourcePathPos, NNConstraint.None);
GraphNode nodeSrc = inf.node;
sourcePathPos = (Vector3)nodeSrc.position;
roadpath = ABPath.Construct(sourcePathPos, destPathPos, null);
roadpath.enabledTags = (1 << 3);
roadpath.calculatePartial = true;
AstarPath.StartPath(roadpath);
yield return (roadpath.WaitForPath());
but the result is ==> roadpath.error = true
This is a really blocking issue, any tips would help a lot…
Best