Hello everyone, I’m trying to implement the PointGraph system for my 2D platform game. But I’m stuck on the following problem:
I have the following function to create point nodes:
public void createPathNodes()
{
AstarPath.RegisterSafeUpdate(delegate ()
{
Vector3 topLeftNode = new Vector2(transform.position.x, extents.y);
Vector3 topRightNode = new Vector2(extents.x, extents.y);
pointGraph.AddNode((Int3) topLeftNode);
pointGraph.AddNode((Int3) topRightNode);
Debug.Log("counter: " + pointGraph.CountNodes());
leftNode = pointGraph.nodes[pointGraph.nodeCount - 2];
rightNode = pointGraph.nodes[pointGraph.nodeCount - 1];
leftNode.AddConnection(rightNode, 0);
rightNode.AddConnection(leftNode, 0);
float d = 0f;
if (pointGraph.IsValidConnection(leftNode, rightNode, out d) == true)
{
Debug.Log(d);//prints ~0.019
}
if (isPlatformLeft) {
platformLeft.connectRightNode(leftNode);
}
if (isPlatformRight) {
platformRight.connectLeftNode(rightNode);
Debug.Log("right");
}
});
AstarPath.active.Scan();
}
The problem is that only 2 point nodes are created (on 1 platform) while this script is attached to multiple platforms. The debug counter also shows that only 2 nodes are created although there should be 2 nodes for each platform.
I’ve tried to fix this problem for awhile now, but it’s quite hard, especially with the lack of pointGraph examples.
Any help is appreciated!