I have followed miziziziz's YouTube video ( https://m.youtube.com/watch?v=A1xjUuRZmWQ ) and setup an astar grid map for an rts demo. But I have been unable to work out how to disable astar points within an area for when placing buildings. I have searched online, and have even looked at dynamic obstacle avoidance, but nothing I could find explains how to disable and re-enable astar points.
Any help is appreciated.
Thank you for your time.
Hi, thanks for answering. I have managed to get the code to work using some spatial nodes placed roughly where the grid points will be, and using something like;
var pointtodisable = astar.getclosestpoint(spatialVector3())
After much trying, I still wasn't able to get the grimap cell reference. Perhaps I have missed something, I haven't worked much with gridmaps yet. How would you go about getting the gridmap index? I looked at how Miziziziz does it in his code, but am still at something of a loss.
As your answer helped me figure out how to disable them using spatials, I will mark it as answered.
this is the best way i think because you can convert between position and index with a function
static func index(x: int, y: int, width: int) -> int:
return int(y * width + x)
static func position(index: int, width: int) -> Vector2:
var y := int(index / float(width))
var x := int(index - width * y)
return Vector2(x, y)
and here is a working example where i disable a point when i close the door and it affects astar pathfinding (can only toggle door when standing beside it and click on it)