Detecting dead paths

Hi,

I am making a TD. It’s pretty standard. Build your own maze. I have the pathing running fine aside from one major issue.
I can easily and pretty much cost free check if a path from start to finish is being blocked. I just have to test a single path from start to finish each time a tower is placed. If it fails then don’ allow them to place it.

Is there any easy way to do this for creeps as well so you can’t block them in? Since it’s a TD there will end up being quite a bit of creeps so looping through each one would get costly fast.

Hi

I think you want to check out this API: http://arongranberg.com/astar/docs/class_pathfinding_1_1_graph_update_utilities.php#afe580774d22ec32a2c7a4ce2cbc4d3fa
That was created specially for this purpose.

okay so I looked it up and tried to implement a quick test, but I keep getting this error when ever it should return false.

NotSupportedException: Positions not supported yet

`
tower = GameObject.Instantiate(Resources.Load<GameObject>("prefabs/tower"), position, Quaternion.identity) as GameObject;

		GraphUpdateObject guo = new GraphUpdateObject(tower.collider.bounds);
(AStarAI.creepOnNode.Values);

		GraphNode n1 = AstarPath.active.GetNearest(new Vector3(-8.5f, 0, 8.5f)).node;

		GraphNode n2 = AstarPath.active.GetNearest(new Vector3(-0.5f, 0, 8.5f)).node;

		bool pathBlocked = pthfinding.GraphUpdateUtilities.UpdateGraphsNoBlock (guo, n1, n2, false); 

		Debug.Log(pathBlocked);
`

The image below shows me carving a path from top down to the left, returns true until I block the path on the edge at which point it gives the error instead of returning false.

Thanks.

oh, sorry. That was a limitation it had in the beta. I have just forgot to remove that limitation.

Here is the correct code for AstarClasses.cs -> GraphUpdateObject.RevertFromBackup

`
public virtual void RevertFromBackup () {
if (trackChangedNodes) {
if (changedNodes == null) return;

	for (int i=0;i<changedNodes.Count;i++) {
		changedNodes[i].Penalty = (uint)(backupData[i]>>32);
		changedNodes[i].Flags = (uint)(backupData[i] & 0xFFFFFFFF);
		changedNodes[i].position = backupPositionData[i];
	}
	
	ListPool<GraphNode>.Release (changedNodes);
	ListPool<ulong>.Release(backupData);
	ListPool<Int3>.Release(backupPositionData);
	changedNodes = null;
	backupData = null;
	backupPositionData = null;
} else {
	throw new System.InvalidOperationException ("Changed nodes have not been tracked, cannot revert from backup");
}

}`

comment removed (was a question starting new question to close this one)

alright so I thought it was working correctly, but I am having an issue with it. It doesn’t seem to want to revert back unless it’s within a range from it. So the creeps just stay still (can’t reach their destination) until I place a tower near the blocked area.

First off in settings I do have
Min Area Size = 0
Max Update Frequency = 0

my code looks like this

This code is only called when a click is performed.

`
tower = GameObject.Instantiate(Resources.Load(“prefabs/tower”), position, Quaternion.identity) as GameObject;
GraphUpdateObject guo = new GraphUpdateObject(tower.collider.bounds);
List nodes = new List(AStarAI.creepOnNode.Values);

	nodes.Add(AstarPath.active.GetNearest(new Vector3(-8.5f, 0, 8.5f)).node);

	bool pathBlocked = Pathfinding.GraphUpdateUtilities.UpdateGraphsNoBlock(guo, nodes, false);

	if (!pathBlocked)
	{
		Destroy(tower);
	}
	Debug.Log("UpdateGraphsNoBlock returned: " + pathBlocked);

`

to better understand the issue I made a video showing what happens.

Thanks.