Adding PointNodes at runtime, I'm stuck

I have an empty PointGraph and I want to add two nodes at runtime and add a connection from one to the other. I managed to add the nodes and the connection, too, and Debug.Log lines indicate that the nodes are added correctly with their correct positions, and the connection is also there. However, when I check IsValidConnection, the distance is around 0.019 (the two nodes are rather far away, so something is already wrong here), and neither the nodes nor the connection shows up as gizmos in the editor view.

PointGraph pointGraph =[0] as PointGraph;
AstarPath.RegisterSafeUpdate(delegate() {
		// Safe to modify graph data here

		Int3 pos1 = new Int3() {
			x = 0, 
			y = 0,
			z = 0
		Int3 pos2 = new Int3() {
			x = 5, 
			y = 0,
			z = 10
		PointNode pn1 = pointGraph.nodes[pointGraph.CountNodes() - 2];
		PointNode pn2 = pointGraph.nodes[pointGraph.CountNodes() - 1];

		float d = 0f;
		if(pointGraph.IsValidConnection(pn1, pn2, out d) == true) {
			Debug.Log(d);//prints ~0.019
           }, true);;

Am I missing a step here?


Node positions are stored as Int3s. These work mostly in the same way as Vector3s, but since they use integers, the numbers are multiplied by Int3.Precision (1000 by default) to be able to represent positions with a higher resolution. You can cast a Vector3 to an Int3 and it will represent the same position in world space.

Int3 pos1 = (Int3)new Vector3 (0, 0, 0);
Int3 pos2 = (Int3)new Vector3 (5, 0, 10);
Debug.Log(pos2); // Will print (5000, 0, 10000);

Note that IsValidConnection is used by the point graph to check if a connection between the nodes should be added (i.e it is within the range limit and not obstructed by an obstacle). If you want to check if a node contains a connection to another node you can use


Also note that connections are one-directional, so if you want to add a connection in both directions you will have to use


Ok, thanks so far. However, the core of my problem remains unsoved: What do I have to do to add nodes and connections to the PointGraph so they are used? So far, I can checkthat the added nodes with their connections exist, but they don’t appear in the scene view (should be blue dots with blue lines, right?), and they are not used by any seekers either.

Edit: Ok, I managed to get it working by replicating what the InternalScan function of PointGenerator does. The only thing that I still wonder about is that the line between both points (which is now showing thankfully) is grey and very hard to see, and it seems like no setting of AstarPath can change it.


Right, one thing you will need after changing connections manually is recalculating the area fields (which are the colors you can see in the scene view). You can call when you are finished updating the nodes.

Thanks, that did it. Now I have a problem using a NavMeshGraph and a PointGraph at the same time with different tags, but I’l open another thread for this.