Point Graph Connections

How do I delete all conections (user links, not auto links)? Delete one by one is the only option?

Unfortunately yes. I am working on a better system for this.
Or if you feel like experimenting. Save the graphs to a file, rename it so it has the zip extension, decompress, open up the .json files and edit the connections directly, then compress it and load the graphs from the new file.

I thought I would just used this thread rather than opening a new one as it’s about point graph connections.

I am struggling to understand how to link nodes together. I set up all my node placements using gameobjects. I scanned to create a graph and I can’t seem to manually change the link connection between nodes. Whenever I click on links and hold shift I get a null reference and all the nodes including the unity gizmo disappear. I have also tried creating the graph through tags and a root object.

Nevertheless, I thought of doing it manually by clicking the add connection button, then moving the nodes into place, but I wanted to confirm whether you can have multiple connections going into 1 node like the scan connections does or if it has to be lots of singular paths going from 1 node to another.

Hi

Getting null reference errors would definitely be a bug. Where are you getting that?
Also, have you scanned the graph before? It needs to be scanned for shift-click to work (though it should just show a warning then).

A node can have any number of connections to other nodes. However only one connection between each pair of nodes (for the A* pathfinding project, it doesn’t really make sense to have multiple connections between two nodes).

I am in the process of making a better system for this, I know the current one is not that good.

Hi.

I get the null reference after holding shift. Inside the Node GetNearest function, it seems to have trouble setting the node array to graph.nodes(Line 2514 in AstarPath but the object reference should be set I would assume after scanning). Well It’s not exactly breaking the game or anything when running the scan connections but I assume this is the warning you mentioned if not scanned and trying to shift click.

Anyways if I place the nodes well enough and mess around with the max distance when scanning, I can get the connections good enough for my needs.

Also I am aware that you are working on a better system as seen on your previous message, but I thought I’ll just let you know. I can’t really complain either except for being grateful that I can test the A* pathfinding through the free version before deciding whether to purchase.

It sounds like you are trying to change the connections via the editor, I’m doing a similar thing but via code so I thought I’d share how I do this :-

I have an empty GameObject in the Heirachy called ‘root’.
And a prefab empty GameObject called ‘pfWaypoint’

In my code I do the following to create the point graph programatically then remove some nodes I dont want.

`// get the root object
 var root = GameObject.FindGameObjectWithTag("root");

// then for every waypoint / node I want to create I instantiate one and assign it to the 
// root object as a child

for( however_many_i_want )
{
   var origin = new Vector3(someX, someY, someZ);
    var wp = (Transform)Instantiate(pfWaypoint, origin, Quaternion.identity);
    wp.transform.parent = root.transform;
    wp.transform.localRotation = Quaternion.identity;
}

// scan the pointgraph so the connections get created
 AstarPath.active.Scan();

// get the pointgraph
 PointGraph pg = AstarPath.active.astarData.pointGraph;

// now for every node in the graph I decide if I want to keep the connection between // it and the nodes its connected to

foreach (var node in pg.nodes)
{
   if( some_logic_to_see_i_keep_this_node)
   {
       // if i dont want the node remove it
       node.RemoveConnection(con);
   } 
}`

Hope that helps.