A* Pathfinding Project

Get closest reacheble node on unreachebla path


#1

Hi! I have dynamic obstacles on my pathes. When I put an obstacle on path, i want my ai go to closest node near this obstacle and then stopped (i don want ai search new path). How can i make this?


#2

As long as a valid path exists from your AI to the obstacle that is placed, you should just be able to use AstarPath.active.GetNearest(obstaclePosition, NNConstraint.Default) to get the position of the closest walkable node to the obstacle. As far as making sure the AI doesn’t search for a new path once it gets there, if you are using the AIPath component on your AI GameObject, this is the default behavior until you give it a new destination. Hope this helps