Prevent the deletion of connections that are in use by agent path

In the game,The agent will find a way to destination on a dynamically created road. If I delete the road after the agent leaves, it will not be able to return to the starting point.How to solve this problem.
I’m trying to mark a node tag for “deletion”,but In some cases, the direction of the connection needs to be considered。Marking all connection directions seems too costly。

Hi there, would you be able to provide a little context about your use case here? It sounds like you’re running your pathfinding logic on a dynamically created road object, having the agent traverse the path, then destroying the road which leads the agent unable to traverse back, since I’m assuming something along the lines like the graph has updated and no longer contains that “road” back? Is that correct?

If I got that all wrong let me know and I’ll see how I can help :slight_smile:

Its right.More specific examples
1 The player creates a road that connects the end and the starting point
2 Once the agent finds the way, they go to the end and back to the starting point
3 The player deletes a portion of the road
4 If the road connecting the start and end points is the only solution,Prevent it from being deleted until the path is no longer needed,and Undeparted agents no longer consider the deleted road

I’ve tried tagging nodes so that agents who are already on the road are still considered traversable, but agents who haven’t departed aren’t considered traversable.Unfortunately, tagged nodes can be used in other directions, and tagged entire nodes are incorrect.I needed a more genius idea

Hey @sunsun

I am a little confused by your inquiry. “If the road connecting the start and end points is the only solution,Prevent it from being deleted until the path is no longer needed,and Undeparted agents no longer consider the deleted road”

How would they return to the starting point if there are no possible paths there?

Is it possible to cache the path to the starting point or ending point ? Perhaps caching the current path in use somewhere else or even more so to have a second graph that is unaffected by player actions and just build a path on the alternative graph for the agent at the times you need accessible nodes

They can’t back starting point after player deleted road.What I’m hoping for is that there is a solution that can guarantee that the agent can still go home when this happens.For example, there is the construction of a temporary road,and When it is no longer needed it is automatically deleted.What stuck me was that I didn’t know how to tell if the temporary road was needed

I’m thinking this might be a good fit for a more customized movement system- are you using AIPath or FollowerEntity or any of the built in movement scripts for your agent?

Hi

It sounds like you want to use PathUtilities - A* Pathfinding Project

You can also check out this section about updating graphs: Graph Updates during Runtime - A* Pathfinding Project
It’s intended for tower-defence games and similar, but I think the same approach could work well for you.

1 Like

I use Script witch inherit AiPath. and working on GridGraph now.