Best Practice: Obstacle Layer?

  • A* version: [5.2.5]
  • Unity version: [60000.0.28f1]
    Hi we are using prefabs and layers (“Obstacle Layer Mask”) to mark cells on our layered grid graph as unwalkable for units. For example all “Walls” are on the “Unwalkable Layer” and therefore block the grid cells.

Now we have 2 questions:

  1. What is the best practice for preventing a object below the floor to count as obstacle

For example when our Environment Designer wants to use a wall piece below the floor like seen here:
Screenshot 2024-12-30 141056
=> The wall piece blocks the bridge above to be walkable

this can only be circumvented by setting the offset to zero in the gridgraph - is this best practice or could this cause issues somewhere else? - Im wondering as the default setting also checks below the floor
Screenshot 2024-12-30 141715
2. sometimes the designer wants to have objects that block the grid on the lower part but not the upper part.
For example the wall here blocks the path below (red arrow) but can be walked on (green arrow):


Any idea what would be the best way to solve this?
I would like to prevent them having to do a “hack” where a lower collider on a gameobject blocks while the upper part does not.

For your first issue, can you set the object to not be tagged/layered as “Obstacle Layer Mask” if it’s
not in a position you want to be an obstacle?

I just tested this to make sure, but yes! You can make the top part walkable by using GraphUpdateScene.

Here’s how I set mine up, and the results:

Yes, this is a good practice. The downside is that it can now miss very small obstacles right on the border between two nodes, since the capsule shape doesn’t cover them. For most games, this is not an issue.

Btw. A recast graph can typically handle objects that the agent can both walk on, and be obstructed by, in a more natural way. For your dungeon, I would recommend trying it out.

1 Like