Removing diagonal node connections

Hi!

I’m trying to remove a connection between nodes (circled in yellow) when two objects are diagonally opposite, image attached (green is tagged and unwalkable, red is walkable). It’s the diagonal line like what the user wants here - Diagonal connections in a simple Grid Graph - I have that connection and I’m trying to detect and remove it.

When I want to block off an area I drop an object on the map, use a new GUO for the bounds of that object, set the walkability and the tag type with a corresponding penalty. After that I might want to clear that specific node connection.

(GraphNode).ClearConnections doesn’t seem to do anything, but I’m probably doing something wrong?

If I use GridGraph.SetNodeConnection to set the connections to false it’ll remove them but only before a GUO is set on the space. Once a GUO is used to set walkability & tag, SetNodeConnection doesn’t remove them.

An example of what happens is I will remove the gameobject from the scene, use SetNodeConnections to delete the connection(s), I’ll see it flash with the connections removed for one frame and then they’re back.

I thought maybe it’s because I’m updating the connections manually, so I wrapped it up in a AStarWorkItem and the same outcome happens. Nothing in my code is rescanning the graph every frame.

Definitely appreciate any help if you have an idea as to what might be going on!

Thanks.

Hi

If you use a GUO and set the walkability to false then that connection should be removed automatically. However if you are using tags then it cannot remove the connection because different units may be able to traverse different sets of tags.

Is there are a reason you are using a tag instead of walkability here?

I don’t ever want the agents to be completely locked in to a no path situation. So the thinking was to use tags to prioritise different types of areas, and if they have to break through something to get to their target then they will, and in the game context that object will be destroyed.

But the one scenario we don’t want is them slipping through the diagonals between two objects. I guess an alternative would be to somehow detect that connection and raise the cost so that the agents don’t see it as a viable alternative to busting through an object?

Hm… Ok. Unfortunately there is no easy way to achieve this I think.
The only way I think is to edit the GridNode class and modify the connection costs there.