A* Tower Defense

Well, im making a tower defense game and when a user create a new tower i need to update the graph(im using a grid graph), so i use AstarPath.active.UpdateGraphs (gameObject.collider.bounds) and it works perfect but the user can also destroy the tower but i dont know how to put the space where the tower was, avaible again.

And another thing, there is a way i can check in the graph if the space is avaible to create a new tower?

UpdateGraphs() should work just fine for rescanning the area once the tower is gone.
`pubic void RemoveTower(subject){
Bounds Subject_area = subject.collider.bounds;

//Destroy tower, display animation, and any other actions here 

AstarPath.active.UpdateGraphs(Subject_area;

}`

http://arongranberg.com/astar/docs/graph-updates.php
This covers in detail how UpdateGraphs() works,

“Check in the graph if the space is avaible to create a new tower?”

I would just use the collider to check if you can place the tower. While you can do it with A*, it would be more resource intensive then just using collision detection.

thanks man, the 1st question helped but i think i wasnt clear enought in the 2nd question, what i mean was if there is a way i can check if the tower is going to block the path, something like that: if i put one tower in the arrow below the path is going to be blocked.

Do a IsPathPossible test before you place a tower:
IsPathPossible

`
pubic bool class CheckBlockedPath(){
return IsPathPossible(Unit_Spawn, Unit_EndPoint);
}

`

Hi

Another solution is to use the UpdateGraphsNoBlock method: http://arongranberg.com/astar/docs/class_pathfinding_1_1_graph_update_utilities.php#af1d9912f395e3a1b5ef4f21d1f19da74 which was specifically designed for this case.