Support Forum

Calling Destroy on PointGraph node causes strange behaviour

I am using a custom point graph, where I add nodes and their connections manually.
Later on, when I need to remove some nodes, I create a new work item and flag them as destroyed:

_astarPath.AddWorkItem(new AstarWorkItem(ctx =>
{
	graphNode.Destroy();
}));

This causes strange behaviour - the rest of the calling method doesn’t finish, so my game stays in a corrupt state.
I tried commenting out the call to .Destroy() method, and everything worked perfectly fine (except for the fact that nodes weren’t destroyed).

What am I doing wrong? Do I need to call destroy from somewhere else?

Hi

Currently, point nodes cannot be destroyed. This is a limitation I really should fix. Sorry about that.
You can however make the nodes unwalkable which has almost the same effect.

But won’t it cause memory issues?
My graph changes a lot during runtime, I am using it for building a path in a strategy game where you can place roads.
Player can remove and build new roads in an instant, so I have to remove old nodes and recalculate parts of graph.

Is it difficult to implement destroying?

Could it be I am using the wrong solution for pathfinding in this case?