Temporary Grid Graph Update using a different obstacle layer mask than the Graph

The Goal: I want to create a walkable object which temporary changes the graph.

The Problem: My Grid Graph uses a different collision testing obstacle layer mask, this one isn’t walkable.

Code:
obraz

What doesn’t work the way I want:
The object is rectangular so using Bounds to get the list of nodes from the corresponding region didn’t work because Bounds has no rotation.
Making the object walkable after changing the graph doesn’t help either.

The Question: What’s the best way of tackling the problem? I’m not sure whether making another graph is a solution but it sounds as an overkill (or am I wrong?) because I’m not using this code frequently.

Hi

I’m not quite sure what you want to do. Could you elaborate?
(please explain what you want to achieve in your game, not a potential solution)

I create a gameobject for 5 seconds and I want the grid graph to mark nodes, that collide with the gameobject, as unwalkable for those 5 seconds. The gameobject by itself has rotation, is walkable and uses a different layer mask than the grid graph does for collision testing (because the one used by grid graph is unwalkable).

Hi

The code you have should work well with one exception, you need to actually delete the Firewall before you update the graph the second time. Otherwise it will still think there’s an obstacle there.

Depending on your version of the package, your version of Unity and your project settings you may also have to call Physics2D.SyncTransforms() before calling UpdateGraphs. This is due to changes in how the unity physics system works.