I wrote a 2D platform graph based on PointNode. It worked well on version 4.2.17 (maybe 4.2.18). The update is finished, and I changed a little code because the scan function changed. I am below some code. Is there something I did wrong?
for (int i = 0; i < platformNodes.Length; i++)
{
//add Connections
int numConnections = platformNodes[i].LinkNodesID.Length;
var connections = new Connection[numConnections];
for (int j = 0; j < numConnections; j++)
{
connections[j].node = graph.BindCreater.GetPlatformNodeByID(platformNodes[i].LinkNodesID[j]).LinkPathNode;
connections[j].cost = (uint)(platformNodes[i].LinkPathNode.position - graph.BindCreater
.GetPlatformNodeByID(platformNodes[i].LinkNodesID[j]).LinkPathNode.position).costMagnitude;
}
graph.nodes[i].connections = connections;
}
//connections number and info all correct there
graph.DebugConnections();
//runtime add graph
var data = AstarPath.active.data;
if (data == null) return;
var platform2DGraph = data.AddGraph(typeof(Platform2DGraph)) as Platform2DGraph;
if(platform2DGraph == null) return;
platform2DGraph.BindCreater = creater;
platform2DGraph.name =creater.BindLocation.name+"PlatformPath";
// scan
var graph = GetCacheGraphByCreater(creater);
if(graph == null) yield break;
foreach (Progress progress in AstarPath.active.ScanAsync(graph)) {
NLog.Log(this,"Scanning -- " +progress.ToString());
yield return null;
}
//use Seeker.StartPath();
// Just Find One Node On Path, and this node connect is 0
private void OnPathComplete(Path p)
{
NLog.Log($"Find {p.ToString()},Is Error? : {p.error}",NLog.LogLevel.Warn);
foreach (var node in p.path)
{
NLog.Log($"path Node ID : {node.NodeIndex} Pos : {(Vector3)node.position}");
node.GetConnections((n =>
{
NLog.Log( $"Connect Id {n.NodeIndex} , Connect Pos : {n.position}");
} ));
}
}
I do a lot of work to debug, and I can confirm all nodes’s connections are 0.